blob: 1baa0612763d7c854ab033131b99fc256cbff437 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limAssocUtils.cc contains the utility functions
30 * LIM uses while processing (Re) Association messages.
31 * Author: Chandra Modumudi
32 * Date: 02/13/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 * 05/26/10 js WPA handling in (Re)Assoc frames
37 *
38 */
39
40#include "palTypes.h"
41#include "aniGlobal.h"
42#include "wniApi.h"
43#include "sirCommon.h"
44
Satyanarayana Dash6f438272015-03-03 18:01:06 +053045#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070046#include "pmmApi.h"
47#include "cfgApi.h"
48
49#include "schApi.h"
50#include "utilsApi.h"
51#include "limUtils.h"
52#include "limAssocUtils.h"
53#include "limSecurityUtils.h"
54#include "limSerDesUtils.h"
55#include "limStaHashApi.h"
56#include "limAdmitControl.h"
57#include "limSendMessages.h"
58#include "limIbssPeerMgmt.h"
59#include "limSession.h"
60
61#include "vos_types.h"
62#include "wlan_qct_wda.h"
63
64/*
65 * fill up the rate info properly based on what is actually supported by the peer
66 * TBD TBD TBD
67 */
68void
69limFillSupportedRatesInfo(
70 tpAniSirGlobal pMac,
71 tpDphHashNode pSta,
72 tpSirSupportedRates pRates,
73 tpPESession psessionEntry)
74{
75 //pSta will be NULL for self entry, so get the opRateMode based on the self mode.
76 //For the peer entry get it from the peer Capabilities present in hash table
77 if(pSta == NULL)
78 pRates->opRateMode = limGetStaRateMode((tANI_U8)psessionEntry->dot11mode);
79 else
80 pRates->opRateMode = limGetStaPeerType(pMac, pSta, psessionEntry);
81
82}
83
84
85/**
86 * limCmpSSid()
87 *
88 *FUNCTION:
89 * This function is called in various places within LIM code
90 * to determine whether received SSid is same as SSID in use.
91 *
92 *LOGIC:
93 *
94 *ASSUMPTIONS:
95 * NA
96 *
97 *NOTE:
98 * NA
99 *
100 * @param *prxSSid - pointer to SSID structure
101 *
102 * @return status - true for SSID match else false.
103 */
104
105tANI_U8
106limCmpSSid(tpAniSirGlobal pMac, tSirMacSSid *prxSSid,tpPESession psessionEntry)
107{
108
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530109 if (vos_mem_compare((tANI_U8* ) prxSSid, (tANI_U8 *) &psessionEntry->ssId,
110 (tANI_U8) (psessionEntry->ssId.length + 1)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700111 return true;
112 else
113 return false;
114
115} /****** end limCmpSSid() ******/
116
117
118
119/**
120 * limCompareCapabilities()
121 *
122 *FUNCTION:
123 * This function is called during Association/Reassociation
124 * frame handling to determine whether received capabilities
125 * match with local capabilities or not.
126 *
127 *LOGIC:
128 *
129 *ASSUMPTIONS:
130 * NA
131 *
132 *NOTE:
133 * NA
134 *
135 * @param pMac - Pointer to Global MAC structure
136 * @param pAssocReq - Pointer to received Assoc Req frame
137 * @param pLocalCapabs - Pointer to local capabilities
138 *
139 * @return status - true for Capabilitity match else false.
140 */
141
142tANI_U8
143limCompareCapabilities(tpAniSirGlobal pMac,
144 tSirAssocReq *pAssocReq,
145 tSirMacCapabilityInfo *pLocalCapabs,tpPESession psessionEntry)
146{
147 tANI_U32 val;
148
149
150 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||
151 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
152 (pAssocReq->capabilityInfo.ibss) )
153 {
154 // Requesting STA asserting IBSS capability.
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530155 limLog(pMac, LOG1,FL("Requesting STA asserting IBSS capability"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 return false;
157 }
158
159 // Compare CF capabilities
160 if (pAssocReq->capabilityInfo.cfPollable ||
161 pAssocReq->capabilityInfo.cfPollReq)
162 {
163 // AP does not support PCF functionality
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530164 limLog(pMac, LOG1,FL(" AP does not support PCF functionality"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 return false;
166 }
167
168#if 0 //See CR24696 for analysis
169 // Compare privacy capability
170 if (pAssocReq->capabilityInfo.privacy != pLocalCapabs->privacy)
171 {
172 // AP does not support privacy
173 return false;
174 }
175#endif
176
177 // Compare short preamble capability
178 if (pAssocReq->capabilityInfo.shortPreamble &&
179 (pAssocReq->capabilityInfo.shortPreamble !=
180 pLocalCapabs->shortPreamble))
181 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530182
183 // Allowing a STA requesting short preamble while
184 // AP does not support it
Jeff Johnson295189b2012-06-20 16:38:30 -0700185#if 0
186 // AP does not support short preamable
187 return false;
188#endif
189 }
190
191
Nirav Shahbc35fb72013-12-12 18:14:06 +0530192 limLog(pMac, LOG1, "QoS in AssocReq: %d, local capabs qos: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 pAssocReq->capabilityInfo.qos,
194 pLocalCapabs->qos);
195
196 // Compare QoS capability
197 if (pAssocReq->capabilityInfo.qos &&
198 (pAssocReq->capabilityInfo.qos != pLocalCapabs->qos))
199 {
200 /*Temporary hack for UPF to skip 11e capability check in order to interop with
201 CSR - proper fix needs to be put in place*/
202 if ( 0 != vos_get_skip_11e_check())
203 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530204 limLog(pMac, LOG1, FL("Received unmatched QOS but cfg to suppress"
205 " - continuing"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 }
207 else
208 {
209 // AP does not support QoS capability
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530210 limLog(pMac, LOG1,FL("AP does not support QoS capability"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 return false;
212 }
213 }
214
215
216 /*
217 * If AP supports shortSlot and if apple user has
218 * enforced association only from shortSlot station,
219 * then AP must reject any station that does not support
220 * shortSlot
221 */
222 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && (pLocalCapabs->shortSlotTime == 1) )
223
224 {
225 if (wlan_cfgGetInt(pMac, WNI_CFG_ACCEPT_SHORT_SLOT_ASSOC_ONLY, &val) != eSIR_SUCCESS)
226 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700227 limLog(pMac, LOGP, FL("error getting WNI_CFG_FORCE_SHORT_SLOT_ASSOC_ONLY "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 return false;
229 }
230 if(val)
231 {
232 if (pAssocReq->capabilityInfo.shortSlotTime != pLocalCapabs->shortSlotTime)
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530233 {
234 limLog(pMac, LOG1,FL("Received shortSlotTime %d does not "
235 "match with local %d"),pAssocReq->capabilityInfo.shortSlotTime,
236 pLocalCapabs->shortSlotTime);
237 return false;
238 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 }
240 }
241
242 return true;
243} /****** end limCompareCapabilities() ******/
244
245
246/**
247 * limCheckRxBasicRates()
248 *
249 *FUNCTION:
250 * This function is called during Association/Reassociation
251 * frame handling to determine whether received rates in
252 * Assoc/Reassoc request frames include all BSS basic rates
253 * or not.
254 *
255 *LOGIC:
256 *
257 *ASSUMPTIONS:
258 * NA
259 *
260 *NOTE:
261 * NA
262 *
263 * @param rxRateSet - pointer to SSID structure
264 *
265 * @return status - true if ALL BSS basic rates are present in the
266 * received rateset else false.
267 */
268
269tANI_U8
270limCheckRxBasicRates(tpAniSirGlobal pMac, tSirMacRateSet rxRateSet,tpPESession psessionEntry)
271{
272 tSirMacRateSet *pRateSet, basicRate;
273 tANI_U8 i, j, k, match;
274
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530275 pRateSet = vos_mem_malloc(sizeof(tSirMacRateSet));
276 if (NULL == pRateSet)
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530278 limLog(pMac, LOGP, FL("call to AllocateMemory failed for RATESET"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280 return false;
281 }
282
283
284 #if 0
285 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
286 (tANI_U8 *) &pRateSet->rate,
287 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
288 {
289 /// Could not get Operational rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700290 limLog(pMac, LOGP, FL("could not retrieve Operational rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700291
292 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530293 vos_mem_free((tANI_U8 *) pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
295 return false;
296 }
297 #endif //TO SUPPORT BT-AMP
298
299 /* Copy operational rate set from session Entry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530300 vos_mem_copy(pRateSet->rate, (psessionEntry->rateSet.rate),
301 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302
303 pRateSet->numRates = psessionEntry->rateSet.numRates;
304
305 // Extract BSS basic rateset from operational rateset
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -0700306 for (i = 0, j = 0; ((i < pRateSet->numRates) && (i < SIR_MAC_RATESET_EID_MAX)) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 {
308 if ((pRateSet->rate[i] & 0x80) == 0x80)
309 {
310 // msb is set, so this is a basic rate
311 basicRate.rate[j++] = pRateSet->rate[i];
312 }
313 }
314
315 /*
316 * For each BSS basic rate, find if it is present in the
317 * received rateset.
318 */
319 for (k = 0; k < j; k++)
320 {
321 match = 0;
Krunal Sonia75019a2013-05-01 01:08:22 -0700322 for (i = 0; ((i < rxRateSet.numRates) && (i < SIR_MAC_RATESET_EID_MAX)); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 {
324 if ((rxRateSet.rate[i] | 0x80) == basicRate.rate[k])
325 match = 1;
326 }
327
328 if (!match)
329 {
330 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530331 vos_mem_free((tANI_U8 *)pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700332
333 return false;
334 }
335 }
336
337 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530338 vos_mem_free((tANI_U8 *)pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700339
340 return true;
341} /****** end limCheckRxBasicRates() ******/
342
343
344
345/**
346 * limCheckMCSSet()
347 *
348 *FUNCTION:
349 * This function is called during Association/Reassociation
350 * frame handling to determine whether received MCS rates in
351 * Assoc/Reassoc request frames includes all Basic MCS Rate Set or not.
352 *
353 *LOGIC:
354 *
355 *ASSUMPTIONS:
356 * NA
357 *
358 *NOTE:
359 * NA
360 *
361 * @param supportedMCSSet - pointer to Supported MCS Rate Set
362 *
363 * @return status - true if ALL MCS Basic Rate Set rates are present in the
364 * received rateset else false.
365 */
366
367tANI_U8
368limCheckMCSSet(tpAniSirGlobal pMac, tANI_U8* supportedMCSSet)
369{
370 tANI_U8 basicMCSSet[SIZE_OF_BASIC_MCS_SET] = {0};
371 tANI_U32 cfgLen = 0;
372 tANI_U8 i;
373 tANI_U8 validBytes;
374 tANI_U8 lastByteMCSMask = 0x1f;
375
376
377 cfgLen = WNI_CFG_BASIC_MCS_SET_LEN;
378 if (wlan_cfgGetStr(pMac, WNI_CFG_BASIC_MCS_SET,
379 (tANI_U8 *) basicMCSSet,
380 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
381 {
382 /// Could not get Basic MCS rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700383 limLog(pMac, LOGP, FL("could not retrieve Basic MCS rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 return false;
385 }
386
387 validBytes = VALID_MCS_SIZE/8;
388
389 //check if all the Basic MCS Bits are set in supported MCS bitmap
390 for(i=0; i<validBytes; i++)
391 {
392 if( (basicMCSSet[i] & supportedMCSSet[i]) != basicMCSSet[i])
393 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530394 //Log is avaiable in calling function in file limProcessAssocReqFrame.c
395 limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is"
396 "not supported by the Station."));
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 return false;
398 }
399 }
400
401 //check the last 5 bits of the valid MCS bitmap
402 if( ((basicMCSSet[i] & lastByteMCSMask) & (supportedMCSSet[i] & lastByteMCSMask)) !=
403 (basicMCSSet[i] & lastByteMCSMask))
404 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530405 //Log is avaiable in calling function in file limProcessAssocReqFrame.c
406 limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is not"
407 "supported by the Station."));
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 return false;
409 }
410
411 return true;
412}
413
Jeff Johnson295189b2012-06-20 16:38:30 -0700414
415#define SECURITY_SUITE_TYPE_MASK 0xFF
416#define SECURITY_SUITE_TYPE_WEP40 0x1
417#define SECURITY_SUITE_TYPE_TKIP 0x2
418#define SECURITY_SUITE_TYPE_CCMP 0x4
419#define SECURITY_SUITE_TYPE_WEP104 0x4
420
421/**
422 * limCheckRxRSNIeMatch()
423 *
424 *FUNCTION:
425 * This function is called during Association/Reassociation
426 * frame handling to determine whether received RSN in
427 * Assoc/Reassoc request frames include supported cipher suites or not.
428 *
429 *LOGIC:
430 *
431 *ASSUMPTIONS:
432 * NA
433 *
434 *NOTE:
435 * NA
436 *
437 * @param rxRSNIe - received RSN IE in (Re)Assco req
438 *
439 * @return status - true if ALL BSS basic rates are present in the
440 * received rateset else false.
441 */
442
443tANI_U8
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700444limCheckRxRSNIeMatch(tpAniSirGlobal pMac, tDot11fIERSN rxRSNIe,tpPESession pSessionEntry,
445 tANI_U8 staIsHT, tANI_BOOLEAN *pmfConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -0700446{
447 tDot11fIERSN *pRSNIe;
448 tANI_U8 i, j, match, onlyNonHtCipher = 1;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700449#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700450 tANI_BOOLEAN weArePMFCapable;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800451 tANI_BOOLEAN weRequirePMF;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700452 tANI_BOOLEAN theyArePMFCapable;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800453 tANI_BOOLEAN theyRequirePMF;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700455
456
457 //RSN IE should be received from PE
458 pRSNIe = &pSessionEntry->gStartBssRSNIe;
459
460 // Check groupwise cipher suite
461 for (i = 0; i < sizeof(rxRSNIe.gp_cipher_suite); i++)
462 {
463 if (pRSNIe->gp_cipher_suite[i] != rxRSNIe.gp_cipher_suite[i])
464 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530465 limLog(pMac, LOG1, FL("RSN group cipher suite does not match local"
466 " %d recieved %d"),pRSNIe->gp_cipher_suite[i],
467 rxRSNIe.gp_cipher_suite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
469 }
470 }
471
472 /*
473 * For each Pairwise cipher suite check whether we support
474 * received pairwise
475 */
476 match = 0;
477 for (i = 0; i < rxRSNIe.pwise_cipher_suite_count; i++)
478 {
479 for(j = 0; j < pRSNIe->pwise_cipher_suite_count; j++)
480 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530481 if (vos_mem_compare(&rxRSNIe.pwise_cipher_suites[i],
482 &pRSNIe->pwise_cipher_suites[j],
483 sizeof(pRSNIe->pwise_cipher_suites[j])))
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 {
485 match = 1;
486 break;
487 }
488 }
489
490 if ((staIsHT)
491#ifdef ANI_LITTLE_BYTE_ENDIAN
492 &&( (rxRSNIe.pwise_cipher_suites[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
493#else
494 &&( (rxRSNIe.pwise_cipher_suites[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
495#endif
496 {
497 onlyNonHtCipher=0;
498 }
499
500 }
501
502 if ((!match) || ((staIsHT) && onlyNonHtCipher))
503 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530504 limLog(pMac, LOG1, FL("pairwise cipher suite does not match(%d)"
505 "staIsHT %d onlyNonHtCipher %d"),match,staIsHT,
506 onlyNonHtCipher);
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 return eSIR_MAC_INVALID_PAIRWISE_CIPHER_STATUS;
508 }
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -0800509 /* Check RSN capabilities
510 * Bit 0 of First Byte - PreAuthentication Capability
511 */
512 if(((rxRSNIe.RSN_Cap[0] >> 0) & 0x1) == true) //this is supported by AP only
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530514 limLog(pMac, LOG1, FL("Preuthentication Capability is set"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 return eSIR_MAC_INVALID_RSN_IE_CAPABILITIES_STATUS;
516 }
517
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700518 *pmfConnection = eANI_BOOLEAN_FALSE;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800519
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700520#ifdef WLAN_FEATURE_11W
Chet Lanctot8cecea22014-02-11 19:09:36 -0800521 weArePMFCapable = pSessionEntry->pLimStartBssReq->pmfCapable;
522 weRequirePMF = pSessionEntry->pLimStartBssReq->pmfRequired;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700523 theyArePMFCapable = (rxRSNIe.RSN_Cap[0] >> 7) & 0x1;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800524 theyRequirePMF = (rxRSNIe.RSN_Cap[0] >> 6) & 0x1;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700525
Chet Lanctotec4de332013-10-11 15:42:22 -0700526 if ((theyRequirePMF && theyArePMFCapable && !weArePMFCapable) ||
527 (weRequirePMF && !theyArePMFCapable))
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700528 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530529 limLog(pMac, LOG1, FL("Association fail, robust management frames "
530 "policy violation theyRequirePMF =%d theyArePMFCapable %d "
531 "weArePMFCapable %d weRequirePMF %d theyArePMFCapable %d"),
532 theyRequirePMF,theyArePMFCapable,weArePMFCapable,weRequirePMF,
533 theyArePMFCapable);
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700534 return eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION;
535 }
536
537 if(theyArePMFCapable && weArePMFCapable)
538 *pmfConnection = eANI_BOOLEAN_TRUE;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800539
540 limLog(pMac, LOG1, FL("weAreCapable %d, weRequire %d, theyAreCapable %d, "
541 "theyRequire %d, PMFconnection %d"),
542 weArePMFCapable, weRequirePMF, theyArePMFCapable, theyRequirePMF, *pmfConnection);
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700543#endif
544
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return eSIR_SUCCESS;
546} /****** end limCheckRxRSNIeMatch() ******/
547
548/**
549 * limCheckRxWPAIeMatch()
550 *
551 *FUNCTION:
552 * This function is called during Association/Reassociation
553 * frame handling to determine whether received RSN in
554 * Assoc/Reassoc request frames include supported cipher suites or not.
555 *
556 *LOGIC:
557 *
558 *ASSUMPTIONS:
559 * NA
560 *
561 *NOTE:
562 * NA
563 *
564 * @param rxWPAIe - Received WPA IE in (Re)Assco req
565 *
566 * @return status - true if ALL BSS basic rates are present in the
567 * received rateset else false.
568 */
569
570tANI_U8
571limCheckRxWPAIeMatch(tpAniSirGlobal pMac, tDot11fIEWPA rxWPAIe,tpPESession pSessionEntry, tANI_U8 staIsHT)
572{
573 tDot11fIEWPA *pWPAIe;
574 tANI_U8 i, j, match, onlyNonHtCipher = 1;
575
576 // WPA IE should be received from PE
577 pWPAIe = &pSessionEntry->gStartBssWPAIe;
578
579 // Check groupwise cipher suite
580 for (i = 0; i < 4; i++)
581 {
582 if (pWPAIe->multicast_cipher[i] != rxWPAIe.multicast_cipher[i])
583 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530584 limLog(pMac, LOG1, FL("WPA group cipher suite does not match local"
585 " %d recieved %d"),pWPAIe->multicast_cipher[i],
586 rxWPAIe.multicast_cipher[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
588 }
589 }
590
591 /*
592 * For each Pairwise cipher suite check whether we support
593 * received pairwise
594 */
595 match = 0;
596 for (i = 0; i < rxWPAIe.unicast_cipher_count; i++)
597 {
598 for(j = 0; j < pWPAIe->unicast_cipher_count; j++)
599 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530600 if (vos_mem_compare(rxWPAIe.unicast_ciphers[i],
601 pWPAIe->unicast_ciphers[j],
602 4))
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 {
604 match = 1;
605 break;
606 }
607 }
608
609 if ((staIsHT)
610#ifdef ANI_LITTLE_BYTE_ENDIAN
611 &&( (rxWPAIe.unicast_ciphers[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
612#else
613 &&( (rxWPAIe.unicast_ciphers[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
614#endif
615 {
616 onlyNonHtCipher=0;
617 }
618
619 }
620
621 if ((!match) || ((staIsHT) && onlyNonHtCipher))
622 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530623 limLog(pMac, LOG1, FL("pairwise cipher suite does not match(%d)"
624 "staIsHT %d onlyNonHtCipher %d"),match,staIsHT,
625 onlyNonHtCipher);
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 return eSIR_MAC_CIPHER_SUITE_REJECTED_STATUS;
627 }
628
629 return eSIR_SUCCESS;
630} /****** end limCheckRxWPAIeMatch() ******/
631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632
633/**
634 * limCleanupRxPath()
635 *
636 *FUNCTION:
637 * This function is called to cleanup STA state at SP & RFP.
638 *
639 *LOGIC:
640 * To circumvent RFP's handling of dummy packet when it does not
641 * have an incomplete packet for the STA to be deleted, a packet
642 * with 'more framgents' bit set will be queued to RFP's WQ before
643 * queuing 'dummy packet'.
644 * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
645 * (Disassociation frame) and routing flags in BD set to eCPU's
646 * Low Priority WQ.
647 * RFP cleans up its local context for the STA id mentioned in the
648 * BD and then pushes BD to eCPU's low priority WQ.
649 *
650 *ASSUMPTIONS:
651 * NA
652 *
653 *NOTE:
654 * NA
655 *
656 * @param pMac Pointer to Global MAC structure
657 * @param pStaDs Pointer to the per STA data structure
658 * initialized by LIM and maintained at DPH
659 *
660 * @return None
661 */
662
663tSirRetStatus
664limCleanupRxPath(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry)
665{
666 tSirRetStatus retCode = eSIR_SUCCESS;
667
668
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530669 limLog( pMac, LOG1, FL("Cleanup Rx Path for AID : %d"
670 "psessionEntry->limSmeState : %d, mlmState : %d"),
671 pStaDs->assocId, psessionEntry->limSmeState,
672 pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 limAbortBackgroundScan( pMac );
Agarwal Ashish87039eb2014-01-15 14:13:15 +0530675 psessionEntry->isCiscoVendorAP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 if (pMac->lim.gLimAddtsSent)
677 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700678 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
680 }
681
682 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
683 {
684 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER,
685 pStaDs->assocId);
686
687 if (!pStaDs->mlmStaContext.updateContext)
688 {
689 /**
690 * There is no context at Polaris to delete.
691 * Release our assigned AID back to the free pool
692 */
kaliu24cedc42016-03-25 11:12:12 +0800693 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
kaliu24cedc42016-03-25 11:12:12 +0800695 {
696 limDelSta(pMac, pStaDs, false, psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800697 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 }
699 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 return retCode;
701 }
702 }
703
704 //delete all tspecs associated with this sta.
705 limAdmitControlDeleteSta(pMac, pStaDs->assocId);
706
Jeff Johnson295189b2012-06-20 16:38:30 -0700707
708 /**
709 * Make STA hash entry invalid at eCPU so that DPH
710 * does not process any more data packets and
711 * releases those BDs
712 */
713 pStaDs->valid = 0;
714 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
715
716 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
717 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700718 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 /* Deactivating probe after heart beat timer */
721 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
Leela Venkata Kiran Kumar Reddy Chiralade5d0592013-09-20 17:09:35 -0700722 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
724 limDeactivateAndChangeTimer(pMac, eLIM_KEEPALIVE_TIMER);
725 pMac->lim.gLastBeaconDtimCount = 0;
726 pMac->lim.gLastBeaconDtimPeriod = 0;
727
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800728#ifdef FEATURE_WLAN_ESE
729#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700730 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
731#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800733#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -0700734#endif
735
736 /**
737 * Update the status for PMM module
738 */
739 pmmResetPmmState(pMac);
740 }
741#ifdef WLAN_DEBUG
742 // increment a debug count
743 pMac->lim.gLimNumRxCleanup++;
744#endif
745
Abhishek Singhde7f0512015-10-23 14:31:15 +0530746 /* Do DEL BSS or DEL STA only if ADD BSS was success */
747 if (!psessionEntry->addBssfailed)
748 {
749 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE)
750 retCode = limDelBss( pMac, pStaDs,
751 psessionEntry->bssIdx, psessionEntry);
752 else
753 retCode = limDelSta( pMac, pStaDs, true, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 return retCode;
756
757} /*** end limCleanupRxPath() ***/
758
759
760/**
761 * limSendDelStaCnf()
762 *
763 *FUNCTION:
764 * This function is called to send appropriate CNF message to SME
765 *
766 *LOGIC:
767 *
768 *
769 *ASSUMPTIONS:
770 * NA
771 *
772 *NOTE:
773 * NA
774 *
775 * @param pMac Pointer to Global MAC structure
776 * @param tpAniSirGlobal pMac,
777 * @param tSirMacAddr staDsAddr,
778 * @param tANI_U16 staDsAssocId,
779 * @param tLimMlmStaContext mlmStaContext,
780 * @param tSirResultCodes statusCode
781 *
782 * @return None
783 */
784
785void
786limSendDelStaCnf(tpAniSirGlobal pMac, tSirMacAddr staDsAddr,
787 tANI_U16 staDsAssocId, tLimMlmStaContext mlmStaContext, tSirResultCodes statusCode,tpPESession psessionEntry)
788{
789
790 tLimMlmDisassocCnf mlmDisassocCnf;
791 tLimMlmDeauthCnf mlmDeauthCnf;
792 tLimMlmPurgeStaInd mlmPurgeStaInd;
793
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530794 limLog(pMac, LOG1, FL("Sessionid: %d staDsAssocId: %d Trigger: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530795 "statusCode: %d staDsAddr: "MAC_ADDRESS_STR),psessionEntry->peSessionId,
796 staDsAssocId, mlmStaContext.cleanupTrigger, statusCode,
797 MAC_ADDR_ARRAY(staDsAddr));
798
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
800 {
801 // Set BSSID at CFG to null
802 tSirMacAddr nullAddr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
803 #if 0
804 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) &nullAddr,
805 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
806 {
807 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700808 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700809
810 return;
811 }
812 #endif//TO SUPPORT BT-AMP
813
814 sirCopyMacAddr(nullAddr,psessionEntry->bssId);
815
816 // Free up buffer allocated for JoinReq held by
817 // MLM state machine
818 if (psessionEntry->pLimMlmJoinReq)
819 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530820 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 psessionEntry->pLimMlmJoinReq = NULL;
822 }
823
824 psessionEntry->limAID = 0;
825
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 }
827
828 if ((mlmStaContext.cleanupTrigger ==
829 eLIM_HOST_DISASSOC) ||
830 (mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530831 eLIM_PROMISCUOUS_MODE_DISASSOC) ||
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 (mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530833 eLIM_LINK_MONITORING_DISASSOC))
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 {
835 /**
836 * Host or LMM driven Disassociation.
837 * Issue Disassoc Confirm to SME.
838 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530839 limLog( pMac, LOGW, FL("Lim Posting DISASSOC_CNF to Sme.Trigger: %d"),
840 mlmStaContext.cleanupTrigger);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841
842
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530843 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
844 (tANI_U8 *) staDsAddr,
845 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 mlmDisassocCnf.resultCode = statusCode;
Wu Gao742b7352015-10-16 19:10:40 +0800847 mlmDisassocCnf.aid = staDsAssocId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 mlmDisassocCnf.disassocTrigger =
849 mlmStaContext.cleanupTrigger;
850 /* Update PE session Id*/
851 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
852
853 limPostSmeMessage(pMac,
854 LIM_MLM_DISASSOC_CNF,
855 (tANI_U32 *) &mlmDisassocCnf);
856 }
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530857 else if ((mlmStaContext.cleanupTrigger == eLIM_HOST_DEAUTH) ||
858 (mlmStaContext.cleanupTrigger == eLIM_LINK_MONITORING_DEAUTH))
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 {
860 /**
861 * Host or LMM driven Deauthentication.
862 * Issue Deauth Confirm to SME.
863 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530864 limLog( pMac, LOGW, FL("Lim Posting DEAUTH_CNF to Sme.Trigger: %d"),
865 mlmStaContext.cleanupTrigger);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530866 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
867 (tANI_U8 *) staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 sizeof(tSirMacAddr));
869 mlmDeauthCnf.resultCode = statusCode;
Wu Gao742b7352015-10-16 19:10:40 +0800870 mlmDeauthCnf.aid = staDsAssocId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 mlmDeauthCnf.deauthTrigger =
872 mlmStaContext.cleanupTrigger;
873 /* PE session Id */
874 mlmDeauthCnf.sessionId = psessionEntry->peSessionId;
875
876 limPostSmeMessage(pMac,
877 LIM_MLM_DEAUTH_CNF,
878 (tANI_U32 *) &mlmDeauthCnf);
879 }
880 else if ((mlmStaContext.cleanupTrigger ==
881 eLIM_PEER_ENTITY_DISASSOC) ||
882 (mlmStaContext.cleanupTrigger ==
883 eLIM_PEER_ENTITY_DEAUTH))
884 {
885 /**
886 * Received Disassociation/Deauthentication from peer.
887 * Issue Purge Ind to SME.
888 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530889 limLog( pMac, LOGW, FL("Lim Posting PURGE_STA_IND to Sme.Trigger: %d"),
890 mlmStaContext.cleanupTrigger) ;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530891 vos_mem_copy((tANI_U8 *) &mlmPurgeStaInd.peerMacAddr,
892 (tANI_U8 *) staDsAddr,
893 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 mlmPurgeStaInd.reasonCode = (tANI_U8) mlmStaContext.disassocReason;
895 mlmPurgeStaInd.aid = staDsAssocId;
896 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
897 mlmPurgeStaInd.sessionId = psessionEntry->peSessionId;
898
899 limPostSmeMessage(pMac,
900 LIM_MLM_PURGE_STA_IND,
901 (tANI_U32 *) &mlmPurgeStaInd);
902 }
903 else if(mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE)
904 {
905 //PE setup the peer entry in HW upfront, right after join is completed.
906 //If there is a failure during rest of the assoc sequence, this context needs to be cleaned up.
907 tANI_U8 smesessionId;
908 tANI_U16 smetransactionId;
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530909 tLimSmeStates tempLimSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700910
911 smesessionId = psessionEntry->smeSessionId;
912 smetransactionId = psessionEntry->transactionId;
913
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530914 tempLimSmeState = psessionEntry->limSmeState;
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700916 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700917
Jeff Johnsone7245742012-09-05 17:12:55 -0700918 //if it is a reassoc failure to join new AP
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530919 //eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA result code is used
920 //during assoc and reassoc, so sme state req to distinguish them
Madan Mohan Koyyalamudif33324b2012-11-06 19:16:17 -0800921 if((mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE) ||
Santhosh Kumar Padmaa2291d72014-05-23 18:08:50 +0530922 (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530923 (mlmStaContext.resultCode == eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE) ||
924 (mlmStaContext.resultCode == eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA
925 && tempLimSmeState == eLIM_SME_WT_REASSOC_STATE)
926 )
Jeff Johnsone7245742012-09-05 17:12:55 -0700927 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530928 limLog( pMac, LOG1, FL("Lim Posting eWNI_SME_REASSOC_RSP to SME"
929 "resultCode: %d, statusCode: %d,"
930 "sessionId: %d"),
931 mlmStaContext.resultCode,
932 mlmStaContext.protStatusCode,
933 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -0700934 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS )
935 {
936 peDeleteSession(pMac, psessionEntry);
937 psessionEntry = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530938 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700939 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
940 mlmStaContext.resultCode, mlmStaContext.protStatusCode, psessionEntry,
941 smesessionId, smetransactionId);
942 }
943 else
944 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530945 vos_mem_free(psessionEntry->pLimJoinReq);
946 psessionEntry->pLimJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700947
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530948 limLog( pMac, LOG1, FL("Lim Posting eWNI_SME_JOIN_RSP to SME."
949 "resultCode: %d,statusCode: %d,"
950 "sessionId: %d"),
951 mlmStaContext.resultCode,
952 mlmStaContext.protStatusCode,
953 psessionEntry->peSessionId);
954 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS)
955 {
956 peDeleteSession(pMac,psessionEntry);
957 psessionEntry = NULL;
958 }
959
960 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, mlmStaContext.resultCode, mlmStaContext.protStatusCode,
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 psessionEntry, smesessionId, smetransactionId);
Jeff Johnsone7245742012-09-05 17:12:55 -0700962 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700963
964 }
965
966 if((NULL != psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 && (eLIM_AP_ROLE != psessionEntry->limSystemRole )
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 )
969 {
970 peDeleteSession(pMac,psessionEntry);
971 psessionEntry = NULL;
972 }
973}
974
975/**
976 * limRejectAssociation()
977 *
978 *FUNCTION:
979 * This function is called whenever Re/Association Request need
980 * to be rejected due to failure in assigning an AID or failure
981 * in adding STA context at Polaris or reject by applications.
982 *
983 *LOGIC:
984 * Resources allocated if any are freedup and (Re) Association
985 * Response frame is sent to requesting STA. Pre-Auth context
986 * will be added for this STA if it does not exist already
987 *
988 *ASSUMPTIONS:
989 *
990 *NOTE:
991 *
992 * @param *pBd - A pointer to Buffer descriptor + associated PDUs
993 * @param subType - Indicates whether it is Association Request (=0) or
994 * Reassociation Request (=1) frame
995 * @param addPreAuthContext - Indicates whether pre-auth context
996 * to be added for this STA
997 * @param authType - Indicates auth type to be added
998 * @param staId - Indicates staId of the STA being rejected
999 * association
1000 * @param deleteSta - Indicates whether to delete STA context
1001 * at Polaris
1002 * @param rCode - Indicates what reasonCode to be sent in
1003 * Re/Assoc response to STA
1004 *
1005 * @return None
1006 */
1007
1008void
1009limRejectAssociation(tpAniSirGlobal pMac, tSirMacAddr peerAddr, tANI_U8 subType,
1010 tANI_U8 addPreAuthContext, tAniAuthType authType,
1011 tANI_U16 staId, tANI_U8 deleteSta, tSirResultCodes rCode, tpPESession psessionEntry )
1012{
1013 tpDphHashNode pStaDs;
Kapil Gupta956c0c42017-06-16 19:24:31 +05301014 assoc_rsp_tx_context *tx_complete_context = NULL;
1015 vos_list_node_t *pNode= NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001016
Abhishek Singhdcbd8272014-01-09 14:16:01 +05301017 limLog(pMac, LOG1, FL("Sessionid: %d authType: %d subType: %d "
1018 "addPreAuthContext: %d staId: %d deleteSta: %d rCode : %d "
1019 "peerAddr: "MAC_ADDRESS_STR),psessionEntry->peSessionId,
1020 authType, subType, addPreAuthContext, staId, deleteSta, rCode,
1021 MAC_ADDR_ARRAY(peerAddr));
1022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 if (addPreAuthContext)
1024 {
1025 // Create entry for this STA in pre-auth list
1026 struct tLimPreAuthNode *pAuthNode;
1027
1028 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1029
1030 if (pAuthNode)
1031 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301032 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 peerAddr,
1034 sizeof(tSirMacAddr));
1035 pAuthNode->fTimerStarted = 0;
1036 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1037 pAuthNode->authType = (tAniAuthType) authType;
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301038 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 limAddPreAuthNode(pMac, pAuthNode);
1040 }
1041 }
1042
1043 if (deleteSta == true)
1044 {
1045 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
1046
1047 if (pStaDs == NULL)
1048 {
1049 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001050 FL("No STA context, yet rejecting Association"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001051
1052 return;
1053 }
Kapil Gupta956c0c42017-06-16 19:24:31 +05301054 vos_list_peek_front(&pMac->assoc_rsp_completion_list, &pNode);
1055
1056 tx_complete_context = vos_mem_malloc(sizeof(*tx_complete_context));
1057 if (!tx_complete_context)
1058 {
1059 limLog(pMac, LOGW,
1060 FL("Failed to allocate memory"));
1061
1062 return;
1063 }
1064 tx_complete_context->psessionID = psessionEntry->peSessionId;
1065 tx_complete_context->staId = staId;
1066
1067 if (pNode)
1068 vos_list_insert_back(&pMac->assoc_rsp_completion_list,
1069 &tx_complete_context->node);
1070 else
1071 vos_list_insert_front(&pMac->assoc_rsp_completion_list,
1072 &tx_complete_context->node);
Jeff Johnson295189b2012-06-20 16:38:30 -07001073
1074 /**
1075 * Polaris has state for this STA.
1076 * Trigger cleanup.
1077 */
1078 pStaDs->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 // Send Re/Association Response with
1080 // status code to requesting STA.
1081 limSendAssocRspMgmtFrame(pMac,
1082 rCode,
1083 0,
1084 peerAddr,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301085 subType, 0,psessionEntry, tx_complete_context);
Jeff Johnson295189b2012-06-20 16:38:30 -07001086
1087 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL)
1088 {
1089 // Assoction confirmation is complete, free the copy of association request frame
1090 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
1091 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301092 vos_mem_free(((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
1094 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301095 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
1097 }
Abhinav Kumara6fa29a2019-01-14 11:21:30 +05301098
Yeshwanth Sriram Guntukab14090a2019-04-12 13:18:05 +05301099 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ADD_STA_RSP_STATE) {
1100 /* Delete hash entry on add sta failure */
1101 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
1102 limDeleteDphHashEntry(pMac, pStaDs->staAddr,
1103 pStaDs->assocId,psessionEntry);
1104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 }
1106 else
1107 {
1108 limSendAssocRspMgmtFrame(pMac,
1109 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
1110 1,
1111 peerAddr,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301112 subType, 0,psessionEntry, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 // Log error
1114 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001115 FL("received Re/Assoc req when max associated STAs reached from "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 limPrintMacAddr(pMac, peerAddr, LOGW);
1117 limSendSmeMaxAssocExceededNtf(pMac, peerAddr, psessionEntry->smeSessionId);
1118 }
1119} /*** end limRejectAssociation() ***/
1120
Jeff Johnson295189b2012-06-20 16:38:30 -07001121
1122/** -------------------------------------------------------------
1123\fn limDecideApProtectionOnHt20Delete
1124\brief protection related function while HT20 station is getting deleted.
1125\param tpAniSirGlobal pMac
1126\param tpDphHashNode pStaDs
1127\param tpUpdateBeaconParams pBeaconParams
1128\return None
1129 -------------------------------------------------------------*/
1130static void
1131limDecideApProtectionOnHt20Delete(tpAniSirGlobal pMac,
1132 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1133{
1134 tANI_U32 i = 0;
1135 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT 20 STA is disassociated. Addr is "),
1136 psessionEntry->gLimHt20Params.numSta);
1137 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1138 if (psessionEntry->gLimHt20Params.numSta > 0)
1139 {
1140 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1141 {
1142 if (psessionEntry->protStaCache[i].active)
1143 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301144 if (vos_mem_compare(psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 pStaDs->staAddr, sizeof(tSirMacAddr)))
1146 {
1147 psessionEntry->gLimHt20Params.numSta--;
1148 psessionEntry->protStaCache[i].active = false;
1149 break;
1150 }
1151 }
1152 }
1153 }
1154
1155 if (psessionEntry->gLimHt20Params.numSta == 0)
1156 {
1157 // disable protection
Nirav Shahbc35fb72013-12-12 18:14:06 +05301158 limLog(pMac, LOG1, FL("No 11B STA exists, PESessionID %d"),
1159 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001160 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
1161 }
1162}
1163/** -------------------------------------------------------------
1164\fn limDecideApProtectionOnDelete
1165\brief Decides about protection related settings when a station is getting deleted.
1166\param tpAniSirGlobal pMac
1167\param tpDphHashNode pStaDs
1168\param tpUpdateBeaconParams pBeaconParams
1169\return None
1170 -------------------------------------------------------------*/
1171void
1172limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
1173 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1174{
1175 tANI_U32 phyMode;
1176 tHalBitVal erpEnabled = eHAL_CLEAR;
1177 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1178 tANI_U32 i;
1179
1180 if(NULL == pStaDs)
1181 return;
1182
1183 limGetRfBand(pMac, &rfBand, psessionEntry);
1184 if(SIR_BAND_5_GHZ == rfBand)
1185 {
1186 //we are HT. if we are 11A, then protection is not required.
Jeff Johnsone7245742012-09-05 17:12:55 -07001187 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 {
1189 //we are HT and 11A station is leaving.
1190 //protection consideration required.
1191 //HT station leaving ==> this case is commonly handled between both the bands below.
1192 if((psessionEntry->beaconParams.llaCoexist) &&
1193 (false == pStaDs->mlmStaContext.htCapability))
1194 {
1195 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11A STA is disassociated. Addr is "),
1196 psessionEntry->gLim11aParams.numSta);
1197 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1198 if (psessionEntry->gLim11aParams.numSta > 0)
1199 {
1200 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1201 {
1202 if (psessionEntry->protStaCache[i].active)
1203 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301204 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 pStaDs->staAddr, sizeof(tSirMacAddr)))
1206 {
1207 psessionEntry->gLim11aParams.numSta--;
1208 psessionEntry->protStaCache[i].active = false;
1209 break;
1210 }
1211 }
1212 }
1213 }
1214
1215 if(psessionEntry->gLim11aParams.numSta == 0)
1216 {
1217 // disable protection
1218 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
1219 }
1220 }
1221 }
1222 }
1223 else if(SIR_BAND_2_4_GHZ == rfBand)
1224 {
1225 limGetPhyMode(pMac, &phyMode, psessionEntry);
1226
1227 erpEnabled = pStaDs->erpEnabled;
1228 //we are HT or 11G and 11B station is getting deleted.
1229 if (((phyMode == WNI_CFG_PHY_MODE_11G) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001230 psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 (erpEnabled == eHAL_CLEAR))
1232 {
1233 PELOG1(limLog(pMac, LOG1, FL("(%d) A legacy STA is disassociated. Addr is "),
1234 psessionEntry->gLim11bParams.numSta);
1235 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1236 if (psessionEntry->gLim11bParams.numSta > 0)
1237 {
1238 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1239 {
1240 if (psessionEntry->protStaCache[i].active)
1241 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301242 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001243 pStaDs->staAddr, sizeof(tSirMacAddr)))
1244 {
1245 psessionEntry->gLim11bParams.numSta--;
1246 psessionEntry->protStaCache[i].active = false;
1247 break;
1248 }
1249 }
1250 }
1251 }
1252
1253 if (psessionEntry->gLim11bParams.numSta == 0)
1254 {
1255 // disable protection
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 limEnable11gProtection(pMac, false, false, pBeaconParams,psessionEntry);
1257 }
1258 }
1259 //(non-11B station is leaving) or (we are not 11G or HT AP)
Jeff Johnsone7245742012-09-05 17:12:55 -07001260 else if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 { //we are HT AP and non-11B station is leaving.
1262
1263 //11g station is leaving
1264 if(!pStaDs->mlmStaContext.htCapability)
1265 {
1266 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11g STA is disassociated. Addr is "),
1267 psessionEntry->gLim11bParams.numSta);
1268 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1269 if (psessionEntry->gLim11gParams.numSta > 0)
1270 {
1271 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1272 {
1273 if (psessionEntry->protStaCache[i].active)
1274 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301275 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 pStaDs->staAddr, sizeof(tSirMacAddr)))
1277 {
1278 psessionEntry->gLim11gParams.numSta--;
1279 psessionEntry->protStaCache[i].active = false;
1280 break;
1281 }
1282 }
1283 }
1284 }
1285
1286 if (psessionEntry->gLim11gParams.numSta == 0)
1287 {
1288 // disable protection
1289 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
1290 }
1291 }
1292 }
1293 }
1294
1295 //LSIG TXOP not supporting staiton leaving. applies to 2.4 as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07001296 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 (true == pStaDs->mlmStaContext.htCapability))
1298 {
1299 //HT non-GF leaving
1300 if(!pStaDs->htGreenfield)
1301 {
1302 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-GF STA is disassociated. Addr is "),
1303 psessionEntry->gLimNonGfParams.numSta);
1304 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1305 if (psessionEntry->gLimNonGfParams.numSta > 0)
1306 {
1307 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1308 {
1309 if (psessionEntry->protStaCache[i].active)
1310 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301311 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 pStaDs->staAddr, sizeof(tSirMacAddr)))
1313 {
1314 psessionEntry->gLimNonGfParams.numSta--;
1315 psessionEntry->protStaCache[i].active = false;
1316 break;
1317 }
1318 }
1319 }
1320 }
1321
1322 if (psessionEntry->gLimNonGfParams.numSta == 0)
1323 {
1324 // disable protection
1325 limEnableHTNonGfProtection(pMac, false, false, pBeaconParams,psessionEntry);
1326 }
1327 }
1328 //HT 20Mhz station leaving.
1329 if(psessionEntry->beaconParams.ht20Coexist &&
1330 (eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet))
1331 {
1332 limDecideApProtectionOnHt20Delete(pMac, pStaDs, pBeaconParams,psessionEntry);
1333 }
1334
1335 if(false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport &&
1336 (false == pStaDs->htLsigTXOPProtection))
1337 {
1338 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is "),
1339 psessionEntry->gLimLsigTxopParams.numSta);
1340 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1341 if (psessionEntry->gLimLsigTxopParams.numSta > 0)
1342 {
1343 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1344 {
1345 if (psessionEntry->protStaCache[i].active)
1346 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301347 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 pStaDs->staAddr, sizeof(tSirMacAddr)))
1349 {
1350 psessionEntry->gLimLsigTxopParams.numSta--;
1351 psessionEntry->protStaCache[i].active = false;
1352 break;
1353 }
1354 }
1355 }
1356 }
1357
1358 if (psessionEntry->gLimLsigTxopParams.numSta == 0)
1359 {
1360 // disable protection
1361 limEnableHTLsigTxopProtection(pMac, true, false, pBeaconParams,psessionEntry);
1362 }
1363 }
1364 }
1365}
1366
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
1368
1369/** -------------------------------------------------------------
1370\fn limDecideShortPreamble
1371\brief Decides about any short preamble reated change because of new station joining.
1372\param tpAniSirGlobal pMac
1373\param tpDphHashNode pStaDs
1374\param tpUpdateBeaconParams pBeaconParams
1375\return None
1376 -------------------------------------------------------------*/
1377void limDecideShortPreamble(tpAniSirGlobal pMac,
1378 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry )
1379{
1380 tANI_U32 i;
1381
1382 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
1383 {
1384 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short preamble STA is disassociated. Addr is "),
1385 psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
1386 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1387 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta > 0)
1388 {
1389 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1390 {
1391 if (psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
1392 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301393 if (vos_mem_compare( psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 pStaDs->staAddr, sizeof(tSirMacAddr)))
1395 {
1396 psessionEntry->gLimNoShortParams.numNonShortPreambleSta--;
1397 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = false;
1398 break;
1399 }
1400 }
1401 }
1402 }
1403
1404 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta == 0)
1405 {
1406 // enable short preamble
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301408 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortParams,
1409 sizeof(tLimNoShortParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 if (limEnableShortPreamble(pMac, true, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001411 PELOGE(limLog(pMac, LOGE, FL("Cannot enable short preamble"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 }
1413 }
1414}
1415
1416/** -------------------------------------------------------------
1417\fn limDecideShortSlot
1418\brief Decides about any short slot time related change because of station leaving the BSS.
1419\param tpAniSirGlobal pMac
1420\param tpDphHashNode pStaDs
1421\return None
1422 -------------------------------------------------------------*/
1423
1424void
1425limDecideShortSlot(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1426 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1427{
1428 tANI_U32 i, val;
1429 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
1430 {
1431 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short slottime STA is disassociated. Addr is "),
1432 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
1433 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1434
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1436 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta> 0)
1437 {
1438 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1439 {
1440 if (psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1441 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301442 if (vos_mem_compare(psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 pStaDs->staAddr, sizeof(tSirMacAddr)))
1444 {
1445 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta--;
1446 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1447 break;
1448 }
1449 }
1450 }
1451 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001452 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001453 {
1454 if (pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta> 0)
1455 {
1456 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1457 {
1458 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1459 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301460 if (vos_mem_compare(pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 pStaDs->staAddr, sizeof(tSirMacAddr)))
1462 {
1463 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta--;
1464 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1465 break;
1466 }
1467 }
1468 }
1469 }
1470 }
1471
1472 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
1473
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1475 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta == 0))
1476 {
1477 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301479 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortSlotParams,
1480 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 // in case of AP set SHORT_SLOT_TIME to enable
1482 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1483 {
1484 pBeaconParams->fShortSlotTime = true;
1485 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001486 psessionEntry->shortSlotTimeSupported = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 }
1488 }
1489 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 {
1491 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta == 0)
1492 {
1493 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301495 vos_mem_set((tANI_U8 *)&pMac->lim.gLimNoShortSlotParams,
1496 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 // in case of AP set SHORT_SLOT_TIME to enable
1498 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1499 {
1500 pBeaconParams->fShortSlotTime = true;
1501 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001502 psessionEntry->shortSlotTimeSupported = true;
1503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 }
1505 }
1506 }
1507}
1508
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001509void
1510limPostReassocFailure(tpAniSirGlobal pMac,
1511 tSirResultCodes resultCode,
1512 tANI_U16 protStatusCode,tpPESession psessionEntry)
1513{
1514 tLimMlmReassocCnf mlmReassocCnf;
1515
1516 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1517 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
1518
1519 // 'Change' timer for future activations
1520 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1521
1522 mlmReassocCnf.resultCode = resultCode;
1523 mlmReassocCnf.protStatusCode = protStatusCode;
1524 /* Update PE session Id */
1525 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1526 limPostSmeMessage(pMac,
1527 LIM_MLM_REASSOC_CNF,
1528 (tANI_U32 *) &mlmReassocCnf);
1529} /*** end limPostReassocFailure() ***/
1530
Jeff Johnson295189b2012-06-20 16:38:30 -07001531/**
1532 * limRestorePreReassocState()
1533 *
1534 *FUNCTION:
1535 * This function is called on STA role whenever Reasociation
1536 * Response with a reject code is received from AP.
1537 *
1538 *LOGIC:
1539 * Reassociation failure timer is stopped, Old (or current) AP's
1540 * context is restored both at Polaris & software
1541 *
1542 *ASSUMPTIONS:
1543 *
1544 *NOTE:
1545 *
1546 * @param pMac - Pointer to Global MAC structure
1547 * @param resultCode - Result code that specifies why Reassociation
1548 * attemp failed
1549 *
1550 * @return None
1551 */
1552
1553void
1554limRestorePreReassocState(tpAniSirGlobal pMac,
1555 tSirResultCodes resultCode,
1556 tANI_U16 protStatusCode,tpPESession psessionEntry)
1557{
Jeff Johnsone7245742012-09-05 17:12:55 -07001558 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 tLimMlmReassocCnf mlmReassocCnf;
1560
Abhishek Singhdcbd8272014-01-09 14:16:01 +05301561 limLog(pMac, LOG1, FL("sessionid: %d protStatusCode: %d resultCode: %d"),
1562 psessionEntry->smeSessionId, protStatusCode, resultCode);
1563
Jeff Johnson295189b2012-06-20 16:38:30 -07001564 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001565 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001566
1567 // 'Change' timer for future activations
1568 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1569
1570 // Update BSSID at CFG database
1571 #if 0
1572 if (cfgSetStr(pMac, WNI_CFG_BSSID,
1573 pMac->lim.gLimCurrentBssId,
1574 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1575 {
1576 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001577 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 return;
1579 }
Madan Mohan Koyyalamudi70322d52012-10-18 20:07:33 -07001580 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001581
1582 // chanNum = pMac->lim.gLimCurrentChannelId;
1583
1584 /* To support BT-AMP */
1585 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07001586 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001587
Jeff Johnsone7245742012-09-05 17:12:55 -07001588 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001589
1590 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1591
1592 mlmReassocCnf.resultCode = resultCode;
1593 mlmReassocCnf.protStatusCode = protStatusCode;
1594 /* Update PE session Id */
1595 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1596 limPostSmeMessage(pMac,
1597 LIM_MLM_REASSOC_CNF,
1598 (tANI_U32 *) &mlmReassocCnf);
1599} /*** end limRestorePreReassocState() ***/
1600
1601
1602
1603/**
1604 * limIsReassocInProgress()
1605 *
1606 *FUNCTION:
1607 * This function is called to see if STA is in wt-reassoc-rsp state.
1608 *
1609 *LOGIC:
1610 *
1611 *ASSUMPTIONS:
1612 *
1613 *NOTE:
1614 *
1615 * @param pMac - Pointer to Global MAC structure
1616 *
1617 * @return eANI_BOOLEAN_TRUE When STA is waiting for Reassoc response from AP \n
1618 * else eANI_BOOLEAN_FALSE
1619 */
1620
1621eAniBoolean
1622limIsReassocInProgress(tpAniSirGlobal pMac,tpPESession psessionEntry)
1623{
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001624 if (psessionEntry == NULL)
1625 {
1626 return eANI_BOOLEAN_FALSE;
1627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 if(((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1629 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1630 (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1631 return eANI_BOOLEAN_TRUE;
1632
1633 return eANI_BOOLEAN_FALSE;
1634} /*** end limIsReassocInProgress() ***/
1635
Jeff Johnsone7245742012-09-05 17:12:55 -07001636#ifdef WLAN_FEATURE_11AC
1637tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
1638 tpSirSupportedRates pRates,
1639 tDot11fIEVHTCaps *pPeerVHTCaps,
1640 tpPESession psessionEntry)
1641{
1642 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001643 tANI_U32 selfStaDot11Mode=0;
1644 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001645
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001646// if(IS_DOT11_MODE_VHT(psessionEntry->dot11mode))
1647 if (IS_DOT11_MODE_VHT(selfStaDot11Mode))
Jeff Johnsone7245742012-09-05 17:12:55 -07001648 {
1649 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_MCS_MAP,&val) !=
1650 eSIR_SUCCESS )
1651 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001652 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001653 goto error;
1654 }
1655 pRates->vhtRxMCSMap = (tANI_U16)val;
1656
1657 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_MCS_MAP,&val ) !=
1658 eSIR_SUCCESS )
1659 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001660 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT TX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001661 goto error;
1662 }
1663 pRates->vhtTxMCSMap = (tANI_U16)val;
1664
1665 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1666 eSIR_SUCCESS )
1667 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001668 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001669 goto error;
1670 }
1671 pRates->vhtRxHighestDataRate = (tANI_U16)val;
1672
1673 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1674 eSIR_SUCCESS )
1675 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001676 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001677 goto error;
1678 }
1679 pRates->vhtTxHighestDataRate = (tANI_U16)val;
1680
1681 if( pPeerVHTCaps != NULL)
1682 {
1683 pRates->vhtTxHighestDataRate = SIR_MIN(pRates->vhtTxHighestDataRate, pPeerVHTCaps->txSupDataRate);
1684 pRates->vhtRxHighestDataRate = SIR_MIN(pRates->vhtRxHighestDataRate, pPeerVHTCaps->rxHighSupDataRate);
1685
Jeff Johnson1250df42012-12-10 14:31:52 -08001686 // Acquire PEER MCS map if we exceed.
Jeff Johnsone7245742012-09-05 17:12:55 -07001687 // We compare/update only the last 2 bits of the map as we support only single BSS.
1688 // Firmware takes care of this comparison
1689 pRates->vhtRxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1690 pRates->vhtRxMCSMap |= (pPeerVHTCaps->rxMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1691
1692 // Firmware takes care of this comparison
1693 pRates->vhtTxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1694 pRates->vhtTxMCSMap |= (pPeerVHTCaps->txMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1695 }
1696 }
1697 return eSIR_SUCCESS;
1698error:
1699
1700 return eSIR_FAILURE;
1701
1702}
1703#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001704
1705/**
1706 * limPopulateOwnRateSet
1707 *
1708 * FUNCTION:
1709 * This function is called by limProcessAssocRsp() or
1710 * limAddStaInIBSS()
1711 * - It creates a combined rate set of 12 rates max which
1712 * comprises the basic and extended rates read from CFG
1713 * - It sorts the combined rate Set and copy it in the
1714 * rate array of the pSTA descriptor
1715 * - It sets the erpEnabled bit of the STA descriptor
1716 *
1717 * NOTE:
1718 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1719 * an A rate in the supported or extended rate sets
1720 *
1721 * @param pMac - Pointer to Global MAC structure
1722 * @param basicOnly - When passed value is true, only basic
1723 * rates are copied to DPH node else
1724 * all supported rates are copied
1725 * @return eSIR_SUCCESS or eSIR_FAILURE
1726 *
1727 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001728#ifdef WLAN_FEATURE_11AC
1729tSirRetStatus
1730limPopulateOwnRateSet(tpAniSirGlobal pMac,
1731 tpSirSupportedRates pRates,
1732 tANI_U8* pSupportedMCSSet,
1733 tANI_U8 basicOnly,
1734 tpPESession psessionEntry,
1735 tDot11fIEVHTCaps *pVHTCaps)
1736#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001737tSirRetStatus
1738limPopulateOwnRateSet(tpAniSirGlobal pMac,
1739 tpSirSupportedRates pRates,
1740 tANI_U8* pSupportedMCSSet,
1741 tANI_U8 basicOnly,
1742 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001743#endif
1744
Jeff Johnson295189b2012-06-20 16:38:30 -07001745{
1746 tSirMacRateSet tempRateSet;
1747 tSirMacRateSet tempRateSet2;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301748 tANI_U32 i,j,val,min,isArate;
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 tANI_U32 phyMode = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001750 tANI_U32 selfStaDot11Mode=0;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301751
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 isArate = 0;
1753
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001754 wlan_cfgGetInt(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 limGetPhyMode(pMac, &phyMode, psessionEntry);
1756
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301757 /* Include 11b rates only when the device configured in
1758 auto, 11a/b/g or 11b_only */
1759 if ( (selfStaDot11Mode == WNI_CFG_DOT11_MODE_ALL) ||
1760 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11A) ||
1761 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11AC) ||
Leela Venkata Kiran Kumar Reddy Chiralac9a10e52013-08-29 16:37:15 -07001762 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11N) ||
1763 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11G) ||
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301764 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11B) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301766 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1767 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11B,
1768 (tANI_U8 *)&tempRateSet.rate, &val );
1769 tempRateSet.numRates = (tANI_U8) val;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001770 }
1771 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301772 tempRateSet.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001773
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301774 /* Include 11a rates when the device configured in non-11b mode */
1775 if (!IS_DOT11_MODE_11B(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301777 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1778 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11A,
1779 (tANI_U8 *)&tempRateSet2.rate, &val );
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 tempRateSet2.numRates = (tANI_U8) val;
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 }
1782 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301783 tempRateSet2.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001784
1785 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1786 {
1787 //we are in big trouble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001788 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 //panic
1790 goto error;
1791 }
1792
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 //copy all rates in tempRateSet, there are 12 rates max
1794 for (i = 0;i < tempRateSet2.numRates; i++)
1795 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1796 tempRateSet.numRates += tempRateSet2.numRates;
1797
1798 /**
1799 * Sort rates in tempRateSet (they are likely to be already sorted)
1800 * put the result in pSupportedRates
1801 */
1802 {
1803 tANI_U8 aRateIndex = 0;
1804 tANI_U8 bRateIndex = 0;
1805
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301806 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 for(i = 0;i < tempRateSet.numRates; i++)
1808 {
1809 min = 0;
1810 val = 0xff;
1811 isArate = 0;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001812 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 {
1814 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1815 {
1816 val = tempRateSet.rate[j] & 0x7f;
1817 min = j;
1818 }
1819 }
1820
1821 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1822 isArate = 1;
1823
1824 /*
1825 * HAL needs to know whether the rate is basic rate or not, as it needs to
1826 * update the response rate table accordingly. e.g. if one of the 11a rates is
1827 * basic rate, then that rate can be used for sending control frames.
1828 * HAL updates the response rate table whenever basic rate set is changed.
1829 */
1830 if (basicOnly)
1831 {
1832 if (tempRateSet.rate[min] & 0x80)
1833 {
1834 if (isArate)
1835 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1836 else
1837 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1838 }
1839 }
1840 else
1841 {
1842 if (isArate)
1843 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1844 else
1845 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1846 }
1847 tempRateSet.rate[min] = 0xff;
1848 }
1849
1850 }
1851
1852
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001853 //if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1854 if (IS_DOT11_MODE_HT(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 {
1856 val = SIZE_OF_SUPPORTED_MCS_SET;
1857 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1858 pRates->supportedMCSSet,
1859 &val) != eSIR_SUCCESS)
1860 {
1861 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001862 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 goto error;
1864 }
1865
1866
1867 //if supported MCS Set of the peer is passed in, then do the intersection
1868 //else use the MCS set from local CFG.
1869
1870 if(pSupportedMCSSet != NULL)
1871 {
1872 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1873 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1874
1875 }
1876
Abhishek Singh525045c2014-12-15 17:18:45 +05301877 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05301879 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 }
1881
Jeff Johnsone7245742012-09-05 17:12:55 -07001882#ifdef WLAN_FEATURE_11AC
1883 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001885
1886 return eSIR_SUCCESS;
1887
1888 error:
1889
1890 return eSIR_FAILURE;
1891} /*** limPopulateOwnRateSet() ***/
1892
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001893#ifdef WLAN_FEATURE_11AC
1894tSirRetStatus
1895limPopulatePeerRateSet(tpAniSirGlobal pMac,
1896
1897 tpSirSupportedRates pRates,
1898 tANI_U8* pSupportedMCSSet,
1899 tANI_U8 basicOnly,
1900 tpPESession psessionEntry,
1901 tDot11fIEVHTCaps *pVHTCaps)
1902#else
1903tSirRetStatus
1904limPopulatePeerRateSet(tpAniSirGlobal pMac,
1905 tpSirSupportedRates pRates,
1906 tANI_U8* pSupportedMCSSet,
1907 tANI_U8 basicOnly,
1908 tpPESession psessionEntry)
1909#endif
1910{
1911 tSirMacRateSet tempRateSet;
1912 tSirMacRateSet tempRateSet2;
1913 tANI_U32 i,j,val,min,isArate;
1914 isArate = 0;
1915
1916 /* copy operational rate set from psessionEntry */
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001917 if ( psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX )
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001918 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301919 vos_mem_copy((tANI_U8 *)tempRateSet.rate,
1920 (tANI_U8*)(psessionEntry->rateSet.rate),
1921 psessionEntry->rateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001922 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1923 }
1924 else
1925 {
1926 limLog(pMac, LOGE, FL("more than SIR_MAC_RATESET_EID_MAX rates\n"));
1927 goto error;
1928 }
Leela Venkata Kiran Kumar Reddy Chirala891bf062013-10-03 14:30:53 -07001929 if ((psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1930 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1931 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11N))
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001932 {
1933
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001934 if (psessionEntry->extRateSet.numRates <= SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001935 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301936 vos_mem_copy((tANI_U8 *)tempRateSet2.rate,
1937 (tANI_U8*)(psessionEntry->extRateSet.rate),
1938 psessionEntry->extRateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001939 tempRateSet2.numRates = psessionEntry->extRateSet.numRates;
1940 }
1941 else {
1942 limLog(pMac, LOGE, FL("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates\n"));
1943 goto error;
1944 }
1945 }
1946 else
1947 tempRateSet2.numRates = 0;
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001948 if ((tempRateSet.numRates + tempRateSet2.numRates) > SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001949 {
1950 //we are in big trouble
1951 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
1952 goto error;
1953 }
1954
1955
1956 //copy all rates in tempRateSet, there are 12 rates max
1957 for (i = 0;i < tempRateSet2.numRates; i++)
1958 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1959 tempRateSet.numRates += tempRateSet2.numRates;
1960 /**
1961 * Sort rates in tempRateSet (they are likely to be already sorted)
1962 * put the result in pSupportedRates
1963 */
1964 {
1965 tANI_U8 aRateIndex = 0;
1966 tANI_U8 bRateIndex = 0;
Kiet Lam842c3e12013-11-16 22:40:57 +05301967 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001968 for(i = 0;i < tempRateSet.numRates; i++)
1969 {
1970 min = 0;
1971 val = 0xff;
1972 isArate = 0;
1973 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
1974 {
1975 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1976 {
1977 val = tempRateSet.rate[j] & 0x7f;
1978 min = j;
1979 }
1980 }
1981 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1982 isArate = 1;
1983 /*
1984 * HAL needs to know whether the rate is basic rate or not, as it needs to
1985 * update the response rate table accordingly. e.g. if one of the 11a rates is
1986 * basic rate, then that rate can be used for sending control frames.
1987 * HAL updates the response rate table whenever basic rate set is changed.
1988 */
1989 if (basicOnly)
1990 {
1991 if (tempRateSet.rate[min] & 0x80)
1992 {
1993 if (isArate)
1994 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1995 else
1996 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1997 }
1998 }
1999 else
2000 {
2001 if (isArate)
2002 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
2003 else
2004 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
2005 }
2006 tempRateSet.rate[min] = 0xff;
2007 }
2008 }
2009
2010
2011 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode))
2012 {
2013 val = SIZE_OF_SUPPORTED_MCS_SET;
2014 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2015 pRates->supportedMCSSet,
2016 &val) != eSIR_SUCCESS)
2017 {
2018 /// Could not get rateset from CFG. Log error.
2019 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
2020 goto error;
2021 }
2022 //if supported MCS Set of the peer is passed in, then do the intersection
2023 //else use the MCS set from local CFG.
2024 if(pSupportedMCSSet != NULL)
2025 {
2026 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2027 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
2028 }
Abhishek Singh525045c2014-12-15 17:18:45 +05302029 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002030 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05302031 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002032 }
2033#ifdef WLAN_FEATURE_11AC
2034 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
2035#endif
2036 return eSIR_SUCCESS;
2037 error:
2038 return eSIR_FAILURE;
2039} /*** limPopulatePeerRateSet() ***/
2040
Jeff Johnson295189b2012-06-20 16:38:30 -07002041/**
2042 * limPopulateMatchingRateSet
2043 * FUNCTION:
2044 * This is called at the time of Association Request
2045 * processing on AP and while adding peer's context
2046 * in IBSS role to process the CFG rate sets and
2047 * the rate sets received in the Assoc request on AP
2048 * or Beacon/Probe Response from peer in IBSS.
2049 *
2050 * LOGIC:
2051 * 1. It makes the intersection between our own rate Sat
2052 * and extemcded rate set and the ones received in the
2053 * association request.
2054 * 2. It creates a combined rate set of 12 rates max which
2055 * comprised the basic and extended rates
2056 * 3. It sorts the combined rate Set and copy it in the
2057 * rate array of the pSTA descriptor
2058 *
2059 * ASSUMPTION:
2060 * The parser has already ensured unicity of the rates in the
2061 * association request structure
2062 *
2063 * @param: pMac - Pointer to Global MAC structure
2064 * pStaDs - Pointer to DPH node
2065 * pOperRateSet - Pointer to peer's supported rateset
2066 * pExtRateSet - Pointer to peer's extended rateset
2067 *
2068 * @return: eSIR_SUCCESS or eSIR_FAILURE
2069 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002070#ifdef WLAN_FEATURE_11AC
2071tSirRetStatus
2072limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2073 tpDphHashNode pStaDs,
2074 tSirMacRateSet *pOperRateSet,
2075 tSirMacRateSet *pExtRateSet,
2076 tANI_U8* pSupportedMCSSet,
2077 tSirMacPropRateSet *pAniLegRateSet,
2078 tpPESession psessionEntry,
2079 tDot11fIEVHTCaps *pVHTCaps)
Jeff Johnson295189b2012-06-20 16:38:30 -07002080
Jeff Johnsone7245742012-09-05 17:12:55 -07002081#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002082tSirRetStatus
2083limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2084 tpDphHashNode pStaDs,
2085 tSirMacRateSet *pOperRateSet,
2086 tSirMacRateSet *pExtRateSet,
2087 tANI_U8* pSupportedMCSSet,
2088 tSirMacPropRateSet *pAniLegRateSet,
2089 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07002090#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002091{
2092 tSirMacRateSet tempRateSet;
2093 tSirMacRateSet tempRateSet2;
2094 tANI_U32 i,j,val,min,isArate;
2095 tANI_U32 phyMode;
2096 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2097
2098 isArate=0;
2099
2100 // limGetPhyMode(pMac, &phyMode);
2101 limGetPhyMode(pMac, &phyMode, psessionEntry);
2102
2103 // get own rate set
2104 // val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2105 #if 0
2106 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2107 (tANI_U8 *) &tempRateSet.rate,
2108 &val) != eSIR_SUCCESS)
2109 {
2110 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002111 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 }
2113
2114 #endif // TO SUPPORT BT-AMP
2115
2116 /* copy operational rate set from psessionEntry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302117 vos_mem_copy((tempRateSet.rate), (psessionEntry->rateSet.rate),
2118 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 tempRateSet.numRates = (tANI_U8) psessionEntry->rateSet.numRates;
2120
2121 if (phyMode == WNI_CFG_PHY_MODE_11G)
2122 {
2123
2124 #if 0
2125 // get own extended rate set
2126 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2127 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
2128 (tANI_U8 *) &tempRateSet2.rate,
2129 &val) != eSIR_SUCCESS)
2130 #endif
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302131 vos_mem_copy((tempRateSet2.rate), (psessionEntry->extRateSet.rate),
2132 psessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 tempRateSet2.numRates = (tANI_U8) psessionEntry->extRateSet.numRates;
2134 }
2135 else
2136 tempRateSet2.numRates = 0;
2137
2138 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2139 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002140 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 goto error;
2142 }
2143
2144 /**
2145 * Handling of the rate set IEs is the following:
2146 * - keep only rates that we support and that the station supports
2147 * - sort and the rates into the pSta->rate array
2148 */
2149
2150 // Copy all rates in tempRateSet, there are 12 rates max
2151 for(i = 0; i < tempRateSet2.numRates; i++)
2152 tempRateSet.rate[i + tempRateSet.numRates] =
2153 tempRateSet2.rate[i];
2154
2155 tempRateSet.numRates += tempRateSet2.numRates;
2156
2157 /**
2158 * Sort rates in tempRateSet (they are likely to be already sorted)
2159 * put the result in tempRateSet2
2160 */
2161 tempRateSet2.numRates = 0;
2162
2163 for(i = 0;i < tempRateSet.numRates; i++)
2164 {
2165 min = 0;
2166 val = 0xff;
2167
2168 for(j = 0;j < tempRateSet.numRates; j++)
2169 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2170 {
2171 val = tempRateSet.rate[j] & 0x7f;
2172 min = j;
2173 }
2174
2175 tempRateSet2.rate[tempRateSet2.numRates++] =
2176 tempRateSet.rate[min];
2177 tempRateSet.rate[min] = 0xff;
2178 }
2179
2180
2181 /**
2182 * Copy received rates in tempRateSet, the parser has ensured
2183 * unicity of the rates so there cannot be more than 12
2184 */
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002185 for(i = 0; (i < pOperRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 {
2187 tempRateSet.rate[i] = pOperRateSet->rate[i];
2188 }
2189
2190 tempRateSet.numRates = pOperRateSet->numRates;
2191
2192 if (pExtRateSet->numRates)
2193 {
2194 if((tempRateSet.numRates + pExtRateSet->numRates) > 12 )
2195 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302196 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 "Sum of SUPPORTED and EXTENDED Rate Set (%1d) exceeds 12!",
2198 tempRateSet.numRates + pExtRateSet->numRates );
2199
2200 if( tempRateSet.numRates < 12 )
2201 {
2202 int found = 0;
2203 int tail = tempRateSet.numRates;
2204
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002205 for( i = 0; (i < pExtRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX); i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 {
2207 found = 0;
2208 for( j = 0; j < (tANI_U32) tail; j++ )
2209 {
2210 if((tempRateSet.rate[j] & 0x7F) ==
2211 (pExtRateSet->rate[i] & 0x7F))
2212 {
2213 found = 1;
2214 break;
2215 }
2216 }
2217
2218 if( !found )
2219 {
2220 tempRateSet.rate[tempRateSet.numRates++] =
2221 pExtRateSet->rate[i];
2222
2223 if( tempRateSet.numRates >= 12 )
2224 break;
2225 }
2226 }
2227 }
2228 else
Abhishek Singh525045c2014-12-15 17:18:45 +05302229 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 "Relying only on the SUPPORTED Rate Set IE..." );
2231 }
2232 else
2233 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002234 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 -07002235 tempRateSet.rate[i+j] = pExtRateSet->rate[j];
2236
2237 tempRateSet.numRates += pExtRateSet->numRates;
2238 }
2239 }
2240
2241 {
2242 tpSirSupportedRates rates = &pStaDs->supportedRates;
2243 tANI_U8 aRateIndex = 0;
2244 tANI_U8 bRateIndex = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302245 vos_mem_set((tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002246 for(i = 0;(i < tempRateSet2.numRates && i < SIR_MAC_RATESET_EID_MAX ); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002248 for(j = 0;(j < tempRateSet.numRates && j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 {
2250 if ((tempRateSet2.rate[i] & 0x7F) ==
2251 (tempRateSet.rate[j] & 0x7F))
2252 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2254 {
2255 isArate=1;
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002256 if (aRateIndex < SIR_NUM_11A_RATES)
2257 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 }
2259 else
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002260 {
2261 if (bRateIndex < SIR_NUM_11B_RATES)
2262 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 break;
2265 }
2266 }
2267 }
2268
2269
2270 //Now add the Polaris rates only when Proprietary rates are enabled.
2271 val = 0;
2272 if(wlan_cfgGetInt(pMac, WNI_CFG_PROPRIETARY_RATES_ENABLED, &val) != eSIR_SUCCESS)
2273 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002274 limLog(pMac, LOGP, FL("could not retrieve prop rate enabled flag from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 }
2276 else if(val)
2277 {
2278 for(i=0; i<pAniLegRateSet->numPropRates; i++)
2279 rates->aniLegacyRates[i] = pAniLegRateSet->propRate[i];
2280 }
2281
2282 }
2283
2284
2285 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002286#ifdef FEATURE_WLAN_TDLS
2287 if(pStaDs->mlmStaContext.htCapability)
2288#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2290 (pStaDs->mlmStaContext.htCapability))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002291#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 {
2293 val = SIZE_OF_SUPPORTED_MCS_SET;
2294 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2295 mcsSet,
2296 &val) != eSIR_SUCCESS)
2297 {
2298 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002299 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 goto error;
2301 }
2302
2303 for(i=0; i<val; i++)
2304 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2305
Abhishek Singh525045c2014-12-15 17:18:45 +05302306 limLog(pMac, LOG1, FL(" MCS Rate Set Bitmap from CFG and DPH : "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2308 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302309 limLog(pMac, LOG1,FL("%x %x "), mcsSet[i],
2310 pStaDs->supportedRates.supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 }
2312 }
2313
Jeff Johnsone7245742012-09-05 17:12:55 -07002314#ifdef WLAN_FEATURE_11AC
2315 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2316#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 /**
2318 * Set the erpEnabled bit iff the phy is in G mode and at least
2319 * one A rate is supported
2320 */
2321 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2322 pStaDs->erpEnabled = eHAL_SET;
2323
2324
2325
2326 return eSIR_SUCCESS;
2327
2328 error:
2329
2330 return eSIR_FAILURE;
2331} /*** limPopulateMatchingRateSet() ***/
2332
2333
2334
2335/**
2336 * limAddSta()
2337 *
2338 *FUNCTION:
2339 * This function is called to add an STA context at hardware
2340 * whenever a STA is (Re) Associated.
2341 *
2342 *LOGIC:
2343 *
2344 *ASSUMPTIONS:
2345 * NA
2346 *
2347 *NOTE:
2348 * NA
2349 *
2350 * @param pMac - Pointer to Global MAC structure
2351 * @param pStaDs - Pointer to the STA datastructure created by
2352 * LIM and maintained by DPH
2353 * @return retCode - Indicates success or failure return code
2354 */
2355
2356tSirRetStatus
2357limAddSta(
2358 tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002359 tpDphHashNode pStaDs, tANI_U8 updateEntry, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002360{
2361 tpAddStaParams pAddStaParams = NULL;
2362 tSirMsgQ msgQ;
2363 tSirRetStatus retCode = eSIR_SUCCESS;
2364 tSirMacAddr staMac, *pStaAddr;
2365 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 tpSirAssocReq pAssocReq;
2367 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 #if 0
2369 retCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2370 if (retCode != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002371 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 #endif //To SUPPORT BT-AMP
2373
2374
2375 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2376
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302377 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
2378 psessionEntry->smeSessionId, updateEntry, psessionEntry->limSystemRole);
2379
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302380 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2381 if (NULL == pAddStaParams)
2382 {
2383 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
2384 return eSIR_MEM_ALLOC_FAILED;
2385 }
2386 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002387
2388 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||
2389 (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE) ||
2390 (limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) )
2391 pStaAddr = &pStaDs->staAddr;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002392#ifdef FEATURE_WLAN_TDLS
2393 /* SystemRole shouldn't be matter if staType is TDLS peer */
2394 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2395 {
2396 pStaAddr = &pStaDs->staAddr ;
2397 }
2398#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 else
2400 pStaAddr = &staMac;
2401
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302402 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": Subtype(Assoc/Reassoc): %d "),
2403 MAC_ADDR_ARRAY(*pStaAddr), pStaDs->mlmStaContext.subType);
2404
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302405 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2406 (tANI_U8 *) *pStaAddr, sizeof(tSirMacAddr));
2407 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2408 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002409
2410 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
2411
2412 //Copy legacy rates
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302413 vos_mem_copy ((tANI_U8*)&pAddStaParams->supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 (tANI_U8*)&pStaDs->supportedRates, sizeof(tSirSupportedRates));
2415
2416 pAddStaParams->assocId = pStaDs->assocId;
2417
2418 pAddStaParams->wmmEnabled = pStaDs->qosMode;
2419 pAddStaParams->listenInterval = pStaDs->mlmStaContext.listenInterval;
2420 pAddStaParams->shortPreambleSupported = pStaDs->shortPreambleEnabled;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302421 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 if((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) && (pStaDs->mlmStaContext.subType == LIM_REASSOC))
2423 {
2424 /* TBD - need to remove this REASSOC check after fixinf rmmod issue */
2425 pAddStaParams->updateSta = pStaDs->mlmStaContext.updateContext;
2426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002427 pStaDs->valid = 0;
2428 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2429
Abhishek Singh525045c2014-12-15 17:18:45 +05302430 limLog(pMac, LOG1, FL(" Assoc ID: %d wmmEnabled = %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302431 " shortPreambleSupported: %d "), pAddStaParams->assocId,
2432 pAddStaParams->wmmEnabled, pAddStaParams->listenInterval,
2433 pAddStaParams->shortPreambleSupported);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002434 // This will indicate HAL to "allocate" a new STA index
2435#ifdef FEATURE_WLAN_TDLS
2436 /* As there is corner case in-between add_sta and change_sta,if del_sta for other staIdx happened,
2437 * firmware return wrong staIdx (recently removed staIdx). Until we get a confirmation from the
2438 * firmware team it is now return correct staIdx for same sta_mac_addr for update case, we want
2439 * to get around it by passing valid staIdx given by add_sta time.
2440 */
2441 if((STA_ENTRY_TDLS_PEER == pStaDs->staType) &&
2442 (true == updateEntry))
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302443 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002444 pAddStaParams->staIdx = pStaDs->staIndex;
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302445 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002446 else
2447#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302448#ifdef SAP_AUTH_OFFLOAD
2449 if (!pMac->sap_auth_offload)
2450 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2451 else
2452 pAddStaParams->staIdx = pStaDs->staIndex;
2453#else
2454 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2455#endif
2456
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 pAddStaParams->staType = pStaDs->staType;
2458
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002459 pAddStaParams->updateSta = updateEntry;
2460
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2462 pAddStaParams->respReqd = 1;
2463 //Update HT Capability
2464
2465 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 -07002466 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Jeff Johnsone7245742012-09-05 17:12:55 -07002468#ifdef WLAN_FEATURE_11AC
2469 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2470#endif
2471 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002472#ifdef FEATURE_WLAN_TDLS
2473 /* SystemRole shouldn't be matter if staType is TDLS peer */
2474 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
Hoonki Lee99e53782013-02-12 18:07:03 -08002475 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002476 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Hoonki Lee99e53782013-02-12 18:07:03 -08002477#ifdef WLAN_FEATURE_11AC
2478 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2479#endif
2480 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002481#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 else
Jeff Johnsone7245742012-09-05 17:12:55 -07002483 {
2484 pAddStaParams->htCapable = psessionEntry->htCapability;
2485#ifdef WLAN_FEATURE_11AC
2486 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
2487#endif
2488
2489 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302490#ifdef WLAN_FEATURE_11AC
Abhishek Singh525045c2014-12-15 17:18:45 +05302491 limLog(pMac, LOG1, FL("vhtCapable: %d "), pAddStaParams->vhtCapable);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302492#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302493 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302494 pAddStaParams->staIdx,pAddStaParams->updateSta,
2495 pAddStaParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002496
2497 pAddStaParams->greenFieldCapable = pStaDs->htGreenfield;
2498 pAddStaParams->maxAmpduDensity= pStaDs->htAMpduDensity;
2499 pAddStaParams->maxAmpduSize = pStaDs->htMaxRxAMpduFactor;
2500 pAddStaParams->fDsssCckMode40Mhz = pStaDs->htDsssCckRate40MHzSupport;
2501 pAddStaParams->fShortGI20Mhz = pStaDs->htShortGI20Mhz;
2502 pAddStaParams->fShortGI40Mhz = pStaDs->htShortGI40Mhz;
2503 pAddStaParams->lsigTxopProtection = pStaDs->htLsigTXOPProtection;
2504 pAddStaParams->maxAmsduSize = pStaDs->htMaxAmsduLength;
2505 pAddStaParams->txChannelWidthSet = pStaDs->htSupportedChannelWidthSet;
2506 pAddStaParams->mimoPS = pStaDs->htMIMOPSState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002507
Abhishek Singh525045c2014-12-15 17:18:45 +05302508 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302509 "maxAmpduDensity = %d"), pAddStaParams->greenFieldCapable,
2510 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
2511
Abhishek Singh525045c2014-12-15 17:18:45 +05302512 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302513 "fShortGI40Mhz: %d"), pAddStaParams->fDsssCckMode40Mhz,
2514 pAddStaParams->fShortGI20Mhz, pAddStaParams->fShortGI40Mhz);
2515
Abhishek Singh525045c2014-12-15 17:18:45 +05302516 limLog(pMac, LOG1, FL("lsigTxopProtection: %d maxAmsduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302517 "txChannelWidthSet: %d mimoPS: %d "), pAddStaParams->lsigTxopProtection,
2518 pAddStaParams->maxAmsduSize,pAddStaParams->txChannelWidthSet,
2519 pAddStaParams->mimoPS);
2520
Jeff Johnsone7245742012-09-05 17:12:55 -07002521#ifdef WLAN_FEATURE_11AC
2522 if(pAddStaParams->vhtCapable)
2523 {
Mohit Khanna7d5aeb22012-09-11 16:21:57 -07002524 pAddStaParams->vhtTxChannelWidthSet = pStaDs->vhtSupportedChannelWidthSet;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002525 pAddStaParams->vhtTxBFCapable =
Hoonki Lee99e53782013-02-12 18:07:03 -08002526#ifdef FEATURE_WLAN_TDLS
2527 (( STA_ENTRY_PEER == pStaDs->staType ) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) ?
2528 pStaDs->vhtBeamFormerCapable : psessionEntry->txBFIniFeatureEnabled ;
2529#else
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002530 ( STA_ENTRY_PEER == pStaDs->staType ) ? pStaDs->vhtBeamFormerCapable :
2531 psessionEntry->txBFIniFeatureEnabled ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002532#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302533 limLog(pMac, LOG1, FL("vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302534 pAddStaParams->vhtTxChannelWidthSet,pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07002535 }
2536#endif
2537
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002538#ifdef FEATURE_WLAN_TDLS
2539 if((STA_ENTRY_PEER == pStaDs->staType) ||
2540 (STA_ENTRY_TDLS_PEER == pStaDs->staType))
2541#else
2542 if (STA_ENTRY_PEER == pStaDs->staType)
2543#endif
2544 {
2545 /* peer STA get the LDPC capability from pStaDs, which populated from
2546 * HT/VHT capability*/
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05302547 if(pAddStaParams->vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP)
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002548 {
2549 pAddStaParams->htLdpcCapable = 0;
2550 pAddStaParams->vhtLdpcCapable = 0;
2551 }
2552 else
2553 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05302554 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
2555 pAddStaParams->htLdpcCapable = pStaDs->htLdpcCapable;
2556 else
2557 pAddStaParams->htLdpcCapable = 0;
2558 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
2559 pAddStaParams->vhtLdpcCapable = pStaDs->vhtLdpcCapable;
2560 else
2561 pAddStaParams->vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002562 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002563 }
2564 else if( STA_ENTRY_SELF == pStaDs->staType)
2565 {
2566 /* For Self STA get the LDPC capability from config.ini*/
2567 pAddStaParams->htLdpcCapable =
2568 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2569 pAddStaParams->vhtLdpcCapable =
2570 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2571 }
2572
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 /* Update PE session ID*/
2574 pAddStaParams->sessionId = psessionEntry->peSessionId;
2575
2576 if (psessionEntry->parsedAssocReq != NULL)
2577 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 // Get a copy of the already parsed Assoc Request
2579 pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pStaDs->assocId];
2580 if ( pAssocReq && pAssocReq->addIEPresent && pAssocReq->addIE.length ) {
2581 p2pIe = limGetP2pIEPtr(pMac, pAssocReq->addIE.addIEdata, pAssocReq->addIE.length);
2582 }
2583 pAddStaParams->p2pCapableSta = (p2pIe != NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 }
2585
2586 //Disable BA. It will be set as part of ADDBA negotiation.
2587 for( i = 0; i < STACFG_MAX_TC; i++ )
2588 {
2589 pAddStaParams->staTCParams[i].txUseBA = eBA_DISABLE;
2590 pAddStaParams->staTCParams[i].rxUseBA = eBA_DISABLE;
2591 }
2592
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002593#ifdef FEATURE_WLAN_TDLS
2594 if(pStaDs->wmeEnabled && \
2595 ((eLIM_AP_ROLE == psessionEntry->limSystemRole) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) )
2596#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 if(pStaDs->wmeEnabled && (eLIM_AP_ROLE == psessionEntry->limSystemRole))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002598#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 {
2600 pAddStaParams->uAPSD = 0;
2601 /* update UAPSD and send it to LIM to add STA */
2602 // bitmap MSB <- LSB MSB 4 bits are for
2603 // trigger enabled AC setting and LSB 4 bits
2604 // are for delivery enabled AC setting
2605 // 7 6 5 4 3 2 1 0
2606 // BE BK VI VO BE BK VI VO
2607 pAddStaParams->uAPSD |= pStaDs->qos.capability.qosInfo.acvo_uapsd;
2608 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acvi_uapsd << 1);
2609 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbk_uapsd << 2);
2610 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbe_uapsd << 3);
2611 //making delivery enabled and trigger enabled setting the same.
2612 pAddStaParams->uAPSD |= pAddStaParams->uAPSD << 4;
2613
2614 pAddStaParams->maxSPLen = pStaDs->qos.capability.qosInfo.maxSpLen;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302615 limLog( pMac, LOG1, FL("uAPSD = 0x%x, maxSpLen = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 pAddStaParams->uAPSD, pAddStaParams->maxSPLen);
2617 }
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002618
2619#ifdef WLAN_FEATURE_11W
2620 pAddStaParams->rmfEnabled = pStaDs->rmfEnabled;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302621 limLog( pMac, LOG1, FL( "PMF enabled %d"), pAddStaParams->rmfEnabled);
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002622#endif
2623
Abhishek Singh525045c2014-12-15 17:18:45 +05302624 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302625 "p2pCapableSta: %d"), pAddStaParams->htLdpcCapable,
2626 pAddStaParams->vhtLdpcCapable, pAddStaParams->p2pCapableSta);
2627
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302628#ifdef SAP_AUTH_OFFLOAD
2629 if (pMac->sap_auth_offload) {
2630 pAddStaParams->dpuIndex = pStaDs->dpuIndex;
2631 pAddStaParams->bcastDpuIndex = pStaDs->bcastDpuIndex;
2632 pAddStaParams->bcastMgmtDpuIdx = pStaDs->bcastMgmtDpuIdx;
2633 pAddStaParams->ucUcastSig = pStaDs->ucUcastSig;
2634 pAddStaParams->ucBcastSig = pStaDs->ucBcastSig;
2635 pAddStaParams->ucMgmtSig = pStaDs->ucMgmtSig;
Agrawal Ashishce67f362017-01-05 20:10:58 +05302636 pAddStaParams->bssIdx = pStaDs->bssId;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302637 }
2638#endif
2639
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002640 //we need to defer the message until we get the response back from HAL.
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 if (pAddStaParams->respReqd)
2642 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002643
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302644#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302645 if (pMac->sap_auth_offload && LIM_IS_AP_ROLE(psessionEntry))
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302646 msgQ.type = WDA_SAP_OFL_ADD_STA;
2647 else
2648 msgQ.type = WDA_ADD_STA_REQ;
2649#else
2650 msgQ.type = WDA_ADD_STA_REQ;
2651#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002652
2653 msgQ.reserved = 0;
2654 msgQ.bodyptr = pAddStaParams;
2655 msgQ.bodyval = 0;
2656
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002657 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ for assocId %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 pStaDs->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002659 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002660
2661 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2662 if( eSIR_SUCCESS != retCode)
2663 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002664 if (pAddStaParams->respReqd)
2665 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002666 limLog( pMac, LOGE, FL("ADD_STA_REQ for aId %d failed (reason %X)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 pStaDs->assocId, retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302668 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 }
2670
2671 return retCode;
2672}
2673
2674
2675/**
2676 * limDelSta()
2677 *
2678 *FUNCTION:
2679 * This function is called to delete an STA context at hardware
2680 * whenever a STA is disassociated
2681 *
2682 *LOGIC:
2683 *
2684 *ASSUMPTIONS:
2685 * NA
2686 *
2687 *NOTE:
2688 * NA
2689 *
2690 * @param pMac - Pointer to Global MAC structure
2691 * @param pStaDs - Pointer to the STA datastructure created by
2692 * LIM and maintained by DPH
2693 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2694 * or not (false)
2695 * @return retCode - Indicates success or failure return code
2696 */
2697
2698tSirRetStatus
2699limDelSta(
2700 tpAniSirGlobal pMac,
2701 tpDphHashNode pStaDs,
2702 tANI_BOOLEAN fRespReqd,
2703 tpPESession psessionEntry)
2704{
2705 tpDeleteStaParams pDelStaParams = NULL;
2706 tSirMsgQ msgQ;
2707 tSirRetStatus retCode = eSIR_SUCCESS;
Sravan Kumar Kairam18705ef2017-09-21 18:37:50 +05302708 tANI_U8 channelNum = 0;
2709 tANI_U32 cfgValue = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002710
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302711 pDelStaParams = vos_mem_malloc(sizeof( tDeleteStaParams ));
2712 if (NULL == pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302714 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 return eSIR_MEM_ALLOC_FAILED;
2716 }
2717
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302718 vos_mem_set((tANI_U8 *) pDelStaParams, sizeof(tDeleteStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002719
Sravan Kumar Kairam18705ef2017-09-21 18:37:50 +05302720 wlan_cfgGetInt(pMac, WNI_CFG_ACTIVE_PASSIVE_CON, &cfgValue);
2721
2722 channelNum = limGetCurrentOperatingChannel(pMac);
2723 limLog(pMac, LOG1, FL("Current Operating channel is %d"), channelNum);
2724 if (!cfgValue && (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) &&
2725 limIsconnectedOnDFSChannel(channelNum))
2726 {
2727 limCovertChannelScanType(pMac, channelNum, false);
2728 pMac->lim.dfschannelList.timeStamp[channelNum] = 0;
2729 }
2730
2731
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 //
2733 // DPH contains the STA index only for "peer" STA entries.
2734 // LIM global contains "self" STA index
2735 // Thus,
2736 // if( STA role )
2737 // get STA index from LIM global
2738 // else
2739 // get STA index from DPH
2740 //
2741
2742#if 0
2743 /* Since we have not created any STA, no need to send msg to delete
2744 * STA to HAL */
2745 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
2746 pDelStaParams->staIdx = 1; /* TODO : This is workaround. Need to find right STA Index before sending to HAL */
2747 //return retCode;
2748 }
2749#endif
2750
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002751#ifdef FEATURE_WLAN_TDLS
2752 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)) )
2753#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 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 -08002755#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 pDelStaParams->staIdx= psessionEntry->staId;
2757
2758 else
2759 pDelStaParams->staIdx= pStaDs->staIndex;
2760
2761 pDelStaParams->assocId = pStaDs->assocId;
2762 pStaDs->valid = 0;
2763
2764 if (! fRespReqd)
2765 pDelStaParams->respReqd = 0;
2766 else
2767 {
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302768 if (pStaDs->staType != STA_ENTRY_TDLS_PEER) {
2769 /**
2770 * when limDelSta is called from processSmeAssocCnf
2771 * then mlmState is already set properly.
2772 */
2773 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
2774 GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs)) {
2775 MTRACE(macTrace
2776 (pMac, TRACE_CODE_MLM_STATE,
2777 psessionEntry->peSessionId,
2778 eLIM_MLM_WT_DEL_STA_RSP_STATE));
2779 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs,
2780 eLIM_MLM_WT_DEL_STA_RSP_STATE);
2781 }
2782 if ((eLIM_STA_ROLE ==
2783 GET_LIM_SYSTEM_ROLE(psessionEntry)) ||
2784 (eLIM_BT_AMP_STA_ROLE ==
2785 GET_LIM_SYSTEM_ROLE(psessionEntry))) {
2786 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
2787 psessionEntry->peSessionId,
2788 eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002789
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302790 psessionEntry->limMlmState =
2791 eLIM_MLM_WT_DEL_STA_RSP_STATE;
2792 }
2793
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 }
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302795 /**
2796 * we need to defer the message until we get the
2797 * response back from HAL.
2798 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302800 pDelStaParams->respReqd = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 }
2802
2803 /* Update PE session ID*/
2804 pDelStaParams->sessionId = psessionEntry->peSessionId;
2805
2806 pDelStaParams->status = eHAL_STATUS_SUCCESS;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302807#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302808 if (pMac->sap_auth_offload && LIM_IS_AP_ROLE(psessionEntry))
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302809 msgQ.type = WDA_SAP_OFL_DEL_STA;
2810 else
2811 msgQ.type = WDA_DELETE_STA_REQ;
2812#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 msgQ.type = WDA_DELETE_STA_REQ;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302814#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 msgQ.reserved = 0;
2816 msgQ.bodyptr = pDelStaParams;
2817 msgQ.bodyval = 0;
2818
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302819 limLog( pMac, LOG1, FL( "Sessionid %d :Sending SIR_HAL_DELETE_STA_REQ "
2820 "for STAID: %X and AssocID: %d MAC : "MAC_ADDRESS_STR ),
2821 pDelStaParams->sessionId,
2822 pDelStaParams->staIdx, pDelStaParams->assocId,
2823 MAC_ADDR_ARRAY(pStaDs->staAddr));
2824
Jeff Johnsone7245742012-09-05 17:12:55 -07002825 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2827 if( eSIR_SUCCESS != retCode)
2828 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002829 if(fRespReqd)
2830 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002831 limLog( pMac, LOGE, FL("Posting DELETE_STA_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302833 vos_mem_free(pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 }
2835
2836 return retCode;
2837}
2838
2839#if defined WLAN_FEATURE_VOWIFI_11R
2840/*------------------------------------------------------------------------
2841 * limAddFTStaSelf()
2842 *
2843 * FUNCTION:
2844 *
2845 * This function is called to add a STA once we have connected with a new
2846 * AP, that we have performed an FT to.
2847 *
2848 * The Add STA Response is created and now after the ADD Bss Is Successful
2849 * we add the self sta. We update with the association id from the reassoc
2850 * response from the AP.
2851 *------------------------------------------------------------------------
2852 */
2853tSirRetStatus limAddFTStaSelf(tpAniSirGlobal pMac, tANI_U16 assocId, tpPESession psessionEntry)
2854{
2855 tpAddStaParams pAddStaParams = NULL;
2856 tSirMsgQ msgQ;
2857 tSirRetStatus retCode = eSIR_SUCCESS;
2858
2859 pAddStaParams = pMac->ft.ftPEContext.pAddStaReq;
2860 pAddStaParams->assocId = assocId;
2861
2862 msgQ.type = SIR_HAL_ADD_STA_REQ;
2863 msgQ.reserved = 0;
2864 msgQ.bodyptr = pAddStaParams;
2865 msgQ.bodyval = 0;
2866
2867
2868#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002869 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ), pAddStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002870#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002871 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002872
2873 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002874 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2876 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2877 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002878 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302879 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 }
2881 //
2882 // Dont need it any more
2883 pMac->ft.ftPEContext.pAddStaReq = NULL;
2884 return retCode;
2885}
2886
2887#endif /* WLAN_FEATURE_VOWIFI_11R */
2888
2889/**
2890 * limAddStaSelf()
2891 *
2892 *FUNCTION:
2893 * This function is called to add an STA context at hardware
2894 * whenever a STA is (Re) Associated.
2895 *
2896 *LOGIC:
2897 *
2898 *ASSUMPTIONS:
2899 * NA
2900 *
2901 *NOTE:
2902 * NA
2903 *
2904 * @param pMac - Pointer to Global MAC structure
2905 * @param pStaDs - Pointer to the STA datastructure created by
2906 * LIM and maintained by DPH
2907 * @return retCode - Indicates success or failure return code
2908 */
2909
2910tSirRetStatus
2911limAddStaSelf(tpAniSirGlobal pMac,tANI_U16 staIdx, tANI_U8 updateSta, tpPESession psessionEntry)
2912{
2913 tpAddStaParams pAddStaParams = NULL;
2914 tSirMsgQ msgQ;
2915 tSirRetStatus retCode = eSIR_SUCCESS;
2916 tSirMacAddr staMac;
2917 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
krunal soni71343fb2013-09-16 16:16:26 -07002918 tANI_U32 shortGi20MhzSupport;
2919 tANI_U32 shortGi40MhzSupport;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302920 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002921 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2922 * that cfg carries the systemwide capability that device under
2923 * consideration can support. This capability gets plumbed into the cfg
2924 * cache at system initialization time via the .dat and .ini file override
2925 * mechanisms and will not change. If it does change, it is the
2926 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2927 * command.*/
2928 tANI_U32 selfStaDot11Mode=0, selfTxWidth=0;
2929 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
2930 limLog( pMac, LOG1, FL("cfgDot11Mode %d"),(int)selfStaDot11Mode);
2931 wlan_cfgGetInt(pMac,WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,&selfTxWidth);
2932 limLog( pMac, LOG1, FL("SGI 20 %d"),(int)selfTxWidth);
2933 limLog( pMac, LOG1, FL("Roam Channel Bonding Mode %d"),(int)pMac->roam.configParam.uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002934
2935 #if 0
2936 retCode =wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2937 if (retCode != eSIR_SUCCESS)
2938 {
2939 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002940 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 return retCode;
2942 }
2943 #endif //TO SUPPORT BT-AMP
2944 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302945 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": "),MAC_ADDR_ARRAY(staMac));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302946 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2947 if (NULL == pAddStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302949 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 return eSIR_MEM_ALLOC_FAILED;
2951 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302952 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
2954 /// Add STA context at MAC HW (BMU, RHP & TFP)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302955 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2956 (tANI_U8 *) staMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002957
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302958 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2959 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002960
2961 pAddStaParams->assocId = psessionEntry->limAID;
2962 pAddStaParams->staType = STA_ENTRY_SELF;
2963 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2964 pAddStaParams->respReqd = 1;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302965 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 /* Update PE session ID */
2967 pAddStaParams->sessionId = psessionEntry->peSessionId;
2968
2969 // This will indicate HAL to "allocate" a new STA index
2970 pAddStaParams->staIdx = staIdx;
2971 pAddStaParams->updateSta = updateSta;
2972
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302973 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
2974 {
2975 limLog(pMac, LOGP, FL("Get short preamble failed. Set Default value"));
2976 pAddStaParams->shortPreambleSupported = 1;
2977 }
2978 pAddStaParams->shortPreambleSupported = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002979
Jeff Johnsone7245742012-09-05 17:12:55 -07002980#ifdef WLAN_FEATURE_11AC
2981 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry,NULL);
2982#else
2983 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
2984#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002985// if( psessionEntry->htCapability)---> old check
2986 /*We used to check if the session is htCapable before setting the htCapable
2987 * flag. The check limited us from operating */
2988 if ( IS_DOT11_MODE_HT(selfStaDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002990 pAddStaParams->htCapable = TRUE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002991#ifdef DISABLE_GF_FOR_INTEROP
2992 /*
2993 * To resolve the interop problem with Broadcom AP,
2994 * where TQ STA could not pass traffic with GF enabled,
2995 * TQ STA will do Greenfield only with TQ AP, for
2996 * everybody else it will be turned off.
2997 */
2998 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2999 {
3000 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
3001 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
3002 }
3003 else
3004#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003005 {
3006 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
3007 pAddStaParams->txChannelWidthSet =
3008 pMac->roam.configParam.channelBondingMode5GHz;
3009 // pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
3010 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
3011 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
3012 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
3013 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
3014 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
3015 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
3016 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
3017 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
krunal soni71343fb2013-09-16 16:16:26 -07003018 /*
3019 * We will read the gShortGI20Mhz from ini file, and if it is set
3020 * to 1 then we will tell Peer that we support 40Mhz short GI
3021 */
3022 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3023 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3024 &shortGi20MhzSupport)))
3025 {
3026 if (VOS_TRUE == shortGi20MhzSupport)
3027 {
3028 pAddStaParams->fShortGI20Mhz =
3029 WNI_CFG_SHORT_GI_20MHZ_STAMAX;
3030 //pAddStaParams->fShortGI20Mhz =
3031 //limGetHTCapability(pMac, eHT_SHORT_GI_20MHZ,
3032 // psessionEntry);
3033 }
3034 else
3035 {
3036 pAddStaParams->fShortGI20Mhz = VOS_FALSE;
3037 }
3038 }
3039 else
3040 {
3041 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3042 "CFG,setting value to default"));)
3043 pAddStaParams->fShortGI20Mhz = WNI_CFG_SHORT_GI_20MHZ_STADEF;
3044 }
3045
3046 /*
3047 * We will read the gShortGI40Mhz from ini file, and if it is set
3048 * to 1 then we will tell Peer that we support 40Mhz short GI
3049 */
3050 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3051 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3052 &shortGi40MhzSupport)))
3053 {
3054 if (VOS_TRUE == shortGi40MhzSupport)
3055 {
3056 pAddStaParams->fShortGI40Mhz =
3057 WNI_CFG_SHORT_GI_40MHZ_STAMAX;
3058 //pAddStaParams->fShortGI40Mhz =
3059 //limGetHTCapability(pMac, eHT_SHORT_GI_40MHZ,
3060 // psessionEntry);
3061 }
3062 else
3063 {
3064 pAddStaParams->fShortGI40Mhz = VOS_FALSE;
3065 }
3066 }
3067 else
3068 {
3069 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3070 "CFG,setting value to default"));)
3071 pAddStaParams->fShortGI40Mhz = WNI_CFG_SHORT_GI_40MHZ_STADEF;
3072 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303073 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303074 "maxAmpduSize = %d"), pAddStaParams->greenFieldCapable,
3075 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
3076
Abhishek Singh525045c2014-12-15 17:18:45 +05303077 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303078 "fShortGI40Mhz: %d lsigTxopProtection: %d"),
3079 pAddStaParams->fDsssCckMode40Mhz, pAddStaParams->fShortGI20Mhz,
3080 pAddStaParams->fShortGI40Mhz, pAddStaParams->lsigTxopProtection);
3081
Abhishek Singh525045c2014-12-15 17:18:45 +05303082 limLog(pMac, LOG1, FL(" maxAmsduSize: %d txChannelWidthSet: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303083 "mimoPS: %d rifsMode %d delBASupport %d"),
3084 pAddStaParams->maxAmsduSize,
3085 pAddStaParams->txChannelWidthSet, pAddStaParams->mimoPS,
3086 pAddStaParams->rifsMode, pAddStaParams->delBASupport );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003089#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003090 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
3091 if (pAddStaParams->vhtCapable){
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003092 pAddStaParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003093 limLog( pMac, LOG1, FL("VHT WIDTH SET %d"),pAddStaParams->vhtTxChannelWidthSet);
3094 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08003095 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Abhishek Singh525045c2014-12-15 17:18:45 +05303096 limLog(pMac, LOG1, FL("vhtCapable: %d vhtTxBFCapable %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303097 pAddStaParams->vhtCapable, pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003098#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003099
3100 /* For Self STA get the LDPC capability from session i.e config.ini*/
3101 pAddStaParams->htLdpcCapable =
3102 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
3103 pAddStaParams->vhtLdpcCapable =
3104 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
3105
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003107 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
3109
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3111 {
3112 pAddStaParams->p2pCapableSta = 1;
3113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003114
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003115 //limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
3116 pAddStaParams->supportedRates.opRateMode = limGetStaRateMode((tANI_U8)selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003117
Abhishek Singh525045c2014-12-15 17:18:45 +05303118 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303119 pAddStaParams->staIdx,pAddStaParams->updateSta,
3120 pAddStaParams->htCapable);
3121
Abhishek Singh525045c2014-12-15 17:18:45 +05303122 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303123 "p2pCapableSta: %d"),
3124 pAddStaParams->htLdpcCapable,pAddStaParams->vhtLdpcCapable,
3125 pAddStaParams->p2pCapableSta);
3126
Abhishek Singh525045c2014-12-15 17:18:45 +05303127 limLog(pMac, LOG1, FL(" sessionid: %d Assoc ID: %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303128 " shortPreambleSupported: %d "), psessionEntry->smeSessionId,
3129 pAddStaParams->assocId, pAddStaParams->listenInterval,
3130 pAddStaParams->shortPreambleSupported);
3131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 msgQ.type = WDA_ADD_STA_REQ;
3133 //
3134 // FIXME_GEN4
3135 // A global counter (dialog token) is required to keep track of
3136 // all PE <-> HAL communication(s)
3137 //
3138 msgQ.reserved = 0;
3139 msgQ.bodyptr = pAddStaParams;
3140 msgQ.bodyval = 0;
3141
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303142 limLog( pMac, LOGW, FL(MAC_ADDRESS_STR":Sessionid %d : "
3143 "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ),
3144 MAC_ADDR_ARRAY(pAddStaParams->staMac),
3145 pAddStaParams->sessionId,
3146 pAddStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07003147 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003148
3149 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3150 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003151 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303152 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 }
3154 return retCode;
3155}
3156
3157
3158/**
3159 * limTeardownInfraBSS()
3160 *
3161 *FUNCTION:
3162 * This function is called by various LIM functions to teardown
3163 * an established Infrastructure BSS
3164 *
3165 *LOGIC:
3166 *
3167 *ASSUMPTIONS:
3168 *
3169 *NOTE:
3170 *
3171 * @param pMac - Pointer to Global MAC structure
3172 * @return None
3173 */
3174
3175void
3176limTeardownInfraBss(tpAniSirGlobal pMac,tpPESession psessionEntry)
3177{
3178 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3179
3180 /**
3181 * Send Broadcast Disassociate frame with
3182 * 'leaving BSS' reason.
3183 */
3184 limSendDisassocMgmtFrame(pMac,
3185 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003186 bcAddr,psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003187} /*** end limTeardownInfraBss() ***/
3188
3189
3190/**
3191 * limHandleCnfWaitTimeout()
3192 *
3193 *FUNCTION:
3194 * This function is called by limProcessMessageQueue to handle
3195 * various confirmation failure cases.
3196 *
3197 *LOGIC:
3198 *
3199 *ASSUMPTIONS:
3200 *
3201 *NOTE:
3202 *
3203 * @param pMac - Pointer to Global MAC structure
3204 * @param pStaDs - Pointer to a sta descriptor
3205 * @return None
3206 */
3207
3208void limHandleCnfWaitTimeout(tpAniSirGlobal pMac, tANI_U16 staId)
3209{
3210 tpDphHashNode pStaDs;
3211 tLimSystemRole systemRole;
3212 tpPESession psessionEntry = NULL;
3213
3214 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId))== NULL)
3215 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003216 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 return;
3218 }
3219 systemRole = limGetSystemRole(psessionEntry);
3220 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
3221
3222 if (pStaDs == NULL)
3223 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003224 PELOGW(limLog(pMac, LOGW, FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 return;
3226 }
3227
3228 switch (pStaDs->mlmStaContext.mlmState) {
3229 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003230 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 -07003231 limPrintMacAddr(pMac, pStaDs->staAddr, LOGW);
3232
3233 if ( (systemRole == eLIM_AP_ROLE)|| (systemRole == eLIM_BT_AMP_AP_ROLE) )
3234 {
3235 limRejectAssociation(
3236 pMac,
3237 pStaDs->staAddr,
3238 pStaDs->mlmStaContext.subType,
3239 true,
3240 pStaDs->mlmStaContext.authType,
3241 pStaDs->assocId,
3242 true,
3243 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
3244 psessionEntry);
3245 }
3246 break;
3247
3248 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003249 limLog(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 pStaDs->mlmStaContext.mlmState);
3251 }
3252}
3253
3254
3255/**
3256 * limDeleteDphHashEntry()
3257 *
3258 *FUNCTION:
3259 * This function is called whenever we need to delete
3260 * the dph hash entry
3261 *
3262 *LOGIC:
3263 *
3264 *ASSUMPTIONS:
3265 *
3266 *NOTE:
3267 *
3268 * @param pMac Pointer to Global MAC structure
3269 * @param tANI_U16 staId
3270 * @return None
3271 */
3272
3273void
3274limDeleteDphHashEntry(tpAniSirGlobal pMac, tSirMacAddr staAddr, tANI_U16 staId,tpPESession psessionEntry)
3275{
3276 tANI_U16 aid;
3277 tpDphHashNode pStaDs;
3278 tUpdateBeaconParams beaconParams;
3279 tLimSystemRole systemRole;
3280
Kaushik, Sushantfb156732014-01-07 15:36:03 +05303281 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 beaconParams.paramChangeBitmap = 0;
3283 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, staId);
3284 if (NULL == psessionEntry)
3285 {
3286 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
3287 return;
3288 }
3289 systemRole = limGetSystemRole(psessionEntry);
3290 beaconParams.bssIdx = psessionEntry->bssIdx;
3291 pStaDs = dphLookupHashEntry(pMac, staAddr, &aid, &psessionEntry->dph.dphHashTable);
3292 if (pStaDs != NULL)
3293 {
3294 PELOGW(limLog(pMac, LOGW, FL("Deleting DPH Hash entry for STAID: %X\n "), staId);)
3295 // update the station count and perform associated actions
3296 // do this before deleting the dph hash entry
3297 limUtilCountStaDel(pMac, pStaDs, psessionEntry);
3298
3299 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||
3300 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
3301 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
3303 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE){
3304 limDecideApProtectionOnDelete(pMac, pStaDs, &beaconParams,psessionEntry);
3305 }
3306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003307
3308 if(eLIM_STA_IN_IBSS_ROLE == systemRole)
3309 limIbssDecideProtectionOnDelete(pMac, pStaDs, &beaconParams, psessionEntry);
3310
3311 limDecideShortPreamble(pMac, pStaDs, &beaconParams, psessionEntry);
3312 limDecideShortSlot(pMac, pStaDs, &beaconParams, psessionEntry);
3313
3314 //Send message to HAL about beacon parameter change.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003315 PELOGW(limLog(pMac, LOGW, FL("param bitmap = %d "), beaconParams.paramChangeBitmap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 if(beaconParams.paramChangeBitmap)
3317 {
3318 schSetFixedBeaconFields(pMac,psessionEntry);
3319 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
3320 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08003321
3322#ifdef WLAN_FEATURE_11W
3323 tx_timer_delete(&pStaDs->pmfSaQueryTimer);
3324#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 }
3326 if (dphDeleteHashEntry(pMac, staAddr, staId, &psessionEntry->dph.dphHashTable) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003327 limLog(pMac, LOGP, FL("error deleting hash entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 }
3329}
3330
3331
3332
3333/**
3334 * limCheckAndAnnounceJoinSuccess()
3335 *
3336 *FUNCTION:
3337 * This function is called upon receiving Beacon/Probe Response
3338 * frame in WT_JOIN_BEACON_STATE to check if the received
3339 * Beacon/Probe Response is from the BSS that we're attempting
3340 * to join.
3341 *
3342 *LOGIC:
3343 * If the Beacon/Probe Response is indeed from the BSS we're
3344 * attempting to join, join success is sent to SME.
3345 *
3346 *ASSUMPTIONS:
3347 *
3348 *NOTE:
3349 *
3350 * @param pMac Pointer to Global MAC structure
3351 * @param pBPR Pointer to received Beacon/Probe Response
3352 * @param pHdr Pointer to received Beacon/Probe Response
3353 * MAC header
3354 * @return None
3355 */
3356
3357void
3358limCheckAndAnnounceJoinSuccess(tpAniSirGlobal pMac,
3359 tSirProbeRespBeacon *pBPR,
3360 tpSirMacMgmtHdr pHdr,tpPESession psessionEntry)
3361{
3362 tSirMacSSid currentSSID;
3363 tLimMlmJoinCnf mlmJoinCnf;
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003364 tANI_U32 val = 0;
3365 tANI_U32 *noa1DurationFromBcn = NULL;
3366 tANI_U32 *noa2DurationFromBcn = NULL;
3367 tANI_U32 noa;
3368 tANI_U32 TotalNum_NoADesc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003369
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303370 vos_mem_copy(currentSSID.ssId,
3371 psessionEntry->ssId.ssId,
3372 psessionEntry->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003373
3374 currentSSID.length = (tANI_U8)psessionEntry->ssId.length ;
3375
3376 if (
3377 /* Check for SSID only in probe response. Beacons may not carry
3378 SSID information in hidden SSID case */
3379 ( (SIR_MAC_MGMT_FRAME == pHdr->fc.type) &&
3380 (SIR_MAC_MGMT_PROBE_RSP == pHdr->fc.subType) ) &&
3381 currentSSID.length &&
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303382 (!vos_mem_compare((tANI_U8 *) &pBPR->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 (tANI_U8 *) &currentSSID,
3384 (tANI_U8) (1 + currentSSID.length)) ))
3385 {
3386 /**
3387 * Received SSID does not match with the one we've.
3388 * Ignore received Beacon frame
3389 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303390 limLog(pMac, LOG1, FL("SSID received in Beacon does not match"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003391#ifdef WLAN_DEBUG
3392 pMac->lim.gLimBcnSSIDMismatchCnt++;
3393#endif
3394 return;
3395 }
3396
3397 if( (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_STA_ROLE))
3398 {
Nirav Shahbc35fb72013-12-12 18:14:06 +05303399 limLog(pMac, LOG1, FL("Received Beacon/PR with matching BSSID"
3400 MAC_ADDRESS_STR "PESessionID %d"),
3401 MAC_ADDR_ARRAY(psessionEntry->bssId),
3402 psessionEntry->peSessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 // Deactivate Join Failure timer
3404 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003405 // Deactivate Periodic Join timer
3406 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07003407
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003408 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona &&
3409 pBPR->P2PProbeRes.NoticeOfAbsence.present)
3410 {
3411
3412 noa1DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3413
3414 if(pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3415 TotalNum_NoADesc = pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc/SIZE_OF_NOA_DESCRIPTOR;
3416
3417 noa = *noa1DurationFromBcn;
3418
3419 if(TotalNum_NoADesc > 1)
3420 {
3421 noa2DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + SIZE_OF_NOA_DESCRIPTOR + 1);
3422 noa += *noa2DurationFromBcn;
3423 }
3424
3425 /*If MAX Noa exceeds 3 secs we will consider only 3 secs to
3426 * avoid arbitary values in noa duration field
3427 */
3428 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ? MAX_NOA_PERIOD_IN_MICROSECS : noa;
3429 noa = noa/1000; //Convert to ms
3430
3431 if( wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,&val) == eSIR_SUCCESS )
3432 {
3433 psessionEntry->defaultAuthFailureTimeout = val;
3434 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,val + noa, NULL, eANI_BOOLEAN_FALSE);
3435 }
3436 }
3437 else
3438 {
3439 psessionEntry->defaultAuthFailureTimeout = 0;
3440 }
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 // Update Beacon Interval at CFG database
3443
3444 if ( pBPR->HTCaps.present )
3445 limUpdateStaRunTimeHTCapability( pMac, &pBPR->HTCaps );
3446 if ( pBPR->HTInfo.present )
3447 limUpdateStaRunTimeHTInfo( pMac, &pBPR->HTInfo, psessionEntry);
3448 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003449 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003450
Ganesh Kondabattiniaad38d92014-11-19 17:06:00 +05303451 /* update the capability info based on recently
3452 * received beacon/probe response frame */
3453 psessionEntry->limCurrentBssCaps = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003454
3455 /**
3456 * Announce join success by sending
3457 * Join confirm to SME.
3458 */
3459 mlmJoinCnf.resultCode = eSIR_SME_SUCCESS;
3460 mlmJoinCnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3461 /* Update PE sessionId*/
3462 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3463 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3464 } // if ((pMac->lim.gLimSystemRole == IBSS....
Abhishek Singh74037df2017-07-20 11:08:56 +05303465
3466 /* Update HS 2.0 Information Element */
3467 sir_copy_hs20_ie(&psessionEntry->hs20vendor_ie, &pBPR->hs20vendor_ie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003468}
3469
3470/**
3471 * limExtractApCapabilities()
3472 *
3473 *FUNCTION:
3474 * This function is called to extract all of the AP's capabilities
3475 * from the IEs received from it in Beacon/Probe Response frames
3476 *
3477 *LOGIC:
3478 * This routine mimics the limExtractApCapability() API. The difference here
3479 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3480 * left to the caller of this API to use this info as required
3481 *
3482 *ASSUMPTIONS:
3483 * NA
3484 *
3485 *NOTE:
3486 *
3487 * @param pMac Pointer to Global MAC structure
3488 * @param pIE Pointer to starting IE in Beacon/Probe Response
3489 * @param ieLen Length of all IEs combined
3490 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3491 * populated
3492 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3493 */
3494tSirRetStatus limExtractApCapabilities( tpAniSirGlobal pMac,
3495 tANI_U8 *pIE,
3496 tANI_U16 ieLen,
3497 tpSirProbeRespBeacon beaconStruct )
3498{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303499 vos_mem_set((tANI_U8 *) beaconStruct, sizeof( tSirProbeRespBeacon ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003500
3501 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003502 FL( "In limExtractApCapabilities: The IE's being received are:" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
3504
3505 // Parse the Beacon IE's, Don't try to parse if we dont have anything in IE
3506 if (ieLen > 0) {
3507 if( eSIR_SUCCESS != sirParseBeaconIE( pMac, beaconStruct, pIE, (tANI_U32)ieLen ))
3508 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003509 limLog( pMac, LOGE, FL("APCapExtract: Beacon parsing error!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 return eSIR_FAILURE;
3511 }
3512 }
3513
3514 return eSIR_SUCCESS;
3515}
3516
3517
3518/**
3519 * limDelBss()
3520 *
3521 *FUNCTION:
3522 * This function is called to delete BSS context at hardware
3523 * whenever a STA is disassociated
3524 *
3525 *LOGIC:
3526 *
3527 *ASSUMPTIONS:
3528 * NA
3529 *
3530 *NOTE:
3531 * NA
3532 *
3533 * @param pMac - Pointer to Global MAC structure
3534 * @param pStaDs - Pointer to the STA datastructure created by
3535 * LIM and maintained by DPH
3536 * @return retCode - Indicates success or failure return code
3537 */
3538
3539tSirRetStatus
3540limDelBss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tANI_U16 bssIdx,tpPESession psessionEntry)
3541{
3542 tpDeleteBssParams pDelBssParams = NULL;
3543 tSirMsgQ msgQ;
3544 tSirRetStatus retCode = eSIR_SUCCESS;
3545
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303546 pDelBssParams = vos_mem_malloc(sizeof(tDeleteBssParams));
3547 if (NULL == pDelBssParams)
3548 {
3549 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 return eSIR_MEM_ALLOC_FAILED;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303551 }
3552 vos_mem_set((tANI_U8 *) pDelBssParams, sizeof(tDeleteBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003553
3554
3555 pDelBssParams->sessionId = psessionEntry->peSessionId; //update PE session Id
3556
3557 //DPH was storing the AssocID in staID field,
3558 //staID is actually assigned by HAL when AddSTA message is sent.
3559 if (pStaDs != NULL)
3560 {
3561 pDelBssParams->bssIdx= pStaDs->bssId;
3562 pStaDs->valid = 0;
3563 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3564 }
3565 else
3566 pDelBssParams->bssIdx = bssIdx;
3567 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003568 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003569
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07003570 if((psessionEntry->peSessionId == pMac->lim.limTimers.gLimJoinFailureTimer.sessionId) &&
3571 (VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)))
3572 {
3573 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
3574 }
3575
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 pDelBssParams->status= eHAL_STATUS_SUCCESS;
3577 pDelBssParams->respReqd = 1;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303578
3579 PELOGW(limLog( pMac, LOGW, FL("Sessionid %d : Sending HAL_DELETE_BSS_REQ "
3580 "for bss idx: %X BSSID:"MAC_ADDRESS_STR), pDelBssParams->sessionId,
3581 pDelBssParams->bssIdx,
3582 MAC_ADDR_ARRAY(psessionEntry->bssId));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003583
3584 //we need to defer the message until we get the response back from HAL.
3585 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3586
3587 msgQ.type = WDA_DELETE_BSS_REQ;
3588 msgQ.reserved = 0;
3589 msgQ.bodyptr = pDelBssParams;
3590 msgQ.bodyval = 0;
3591
Jeff Johnsone7245742012-09-05 17:12:55 -07003592 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003593
3594 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3595 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003596 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003597 limLog( pMac, LOGE, FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303598 vos_mem_free(pDelBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 }
3600
3601 return retCode;
3602}
3603
3604
Jeff Johnson295189b2012-06-20 16:38:30 -07003605
3606/**
3607 * limSendAddBss()
3608 *
3609 *FUNCTION:
3610 *
3611 *LOGIC:
3612 * 1) LIM receives eWNI_SME_JOIN_REQ
3613 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3614 * SIR_HAL_ADD_BSS_REQ to HAL
3615 *
3616 *ASSUMPTIONS:
3617 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3618 * ADD BSS parameters can be obtained from two sources:
3619 * 1) pMac->lim.gLimMlmJoinReq
3620 * 2) beaconStruct, passed as paramter
3621 * So, if a reqd parameter is found in bssDescriptions
3622 * then it is given preference over beaconStruct
3623 *
3624 *NOTE:
3625 *
3626 * @param pMac Pointer to Global MAC structure
3627 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3628 * beaconstruct Has the ProbeRsp/Beacon structured details
3629 * bssDescription bssDescription passed to PE from the SME
3630 * @return None
3631 */
3632
3633tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3634 tpSchBeaconStruct pBeaconStruct, tpSirBssDescription bssDescription, tANI_U8 updateEntry,
3635 tpPESession psessionEntry)
3636
3637{
3638 tSirMsgQ msgQ;
3639 tpAddBssParams pAddBssParams = NULL;
3640 tANI_U32 retCode;
3641 tANI_U8 i;
3642 tpDphHashNode pStaDs = NULL;
3643 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003644 tANI_U32 shortGi20MhzSupport;
3645 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303647 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
3648 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 {
3650 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303651 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 retCode = eSIR_MEM_ALLOC_FAILED;
3653 goto returnFailure;
3654 }
3655 else
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303656 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003657
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303658 vos_mem_copy(pAddBssParams->bssId,bssDescription->bssId,
3659 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303661 vos_mem_copy(pAddBssParams->selfMacAddr,
3662 psessionEntry->selfMacAddr,
3663 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303664
3665 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
3666 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
3667
3668 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
3669 MAC_ADDR_ARRAY(pAddBssParams->bssId));
3670
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3672 {
3673 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3674 }
3675 else
3676 {
3677 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3678 }
3679
3680 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3681
3682 /* Update PE session ID */
3683 pAddBssParams->sessionId = psessionEntry->peSessionId;
3684
3685 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3686
3687 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3688 pAddBssParams->updateBss = updateEntry;
3689
3690
3691 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3692 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3693 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3694 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
3695
3696 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303697 vos_mem_copy(pAddBssParams->rateSet.rate,
3698 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003699
3700 pAddBssParams->nwType = bssDescription->nwType;
3701
Jeff Johnsone7245742012-09-05 17:12:55 -07003702 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3704 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3705 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3706 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3707
Abhishek Singh525045c2014-12-15 17:18:45 +05303708 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303709 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
3710 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
3711
Abhishek Singh525045c2014-12-15 17:18:45 +05303712 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303713 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
3714 pAddBssParams->cfParamSet.cfpMaxDuration,
3715 pAddBssParams->cfParamSet.cfpDurRemaining,
3716 pAddBssParams->rateSet.numRates);
3717
Abhishek Singh525045c2014-12-15 17:18:45 +05303718 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303719 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
3720 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
3721 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
3722 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07003723
3724 // Use the advertised capabilities from the received beacon/PR
3725
3726
3727 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3728 {
3729 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05303730 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 if ( pBeaconStruct->HTInfo.present )
3732 {
3733 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pAssocRsp->HTInfo.opMode;
3734 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pAssocRsp->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3737 (chanWidthSupp) )
3738 {
3739 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3740 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3741 }
3742 else
3743 {
3744 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003745 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 }
3747 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3748 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3749 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303750
Abhishek Singh525045c2014-12-15 17:18:45 +05303751 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303752 "txChannelWidthSet: %d currentExtChannel: %d "),
3753 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
3754 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
3755
Abhishek Singh525045c2014-12-15 17:18:45 +05303756 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303757 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
3758 pAddBssParams->llnNonGFCoexist,
3759 pAddBssParams->fLsigTXOPProtectionFullSupport,
3760 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 }
3762 }
3763
3764 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05303765 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303766 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003767#ifdef WLAN_FEATURE_11AC
3768 if (psessionEntry->vhtCapability && ( pAssocRsp->VHTCaps.present ))
3769 {
3770 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3771 pAddBssParams->vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth;
3772 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003773 pAddBssParams->currentOperChannel,
3774 pAddBssParams->currentExtChannel,
3775 psessionEntry->apCenterChan,
3776 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003777 }
3778 else
3779 {
3780 pAddBssParams->vhtCapable = 0;
3781 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303782 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303783 "currentExtChannel %d"),pAddBssParams->vhtCapable,
3784 pAddBssParams->vhtTxChannelWidthSet,
3785 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003786#endif
3787
3788
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 // Populate the STA-related parameters here
3790 // Note that the STA here refers to the AP
3791 {
3792 /* staType = PEER*/
3793 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3794
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303795 vos_mem_copy(pAddBssParams->staContext.bssId,
3796 bssDescription->bssId,
3797 sizeof( tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3799
3800 /* Fill Assoc id from the dph table */
3801 pStaDs = dphLookupHashEntry(pMac, pAddBssParams->staContext.bssId,
3802 &pAddBssParams->staContext.assocId, &psessionEntry->dph.dphHashTable);
3803 if (pStaDs == NULL)
3804 {
Arif Hussain24bafea2013-11-15 15:10:03 -08003805 PELOGE(limLog(pMac, LOGE, FL("Couldn't get assoc id for "
3806 "MAC ADDR: " MAC_ADDRESS_STR),
3807 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 }
3809 pAddBssParams->staContext.uAPSD = 0;
3810 pAddBssParams->staContext.maxSPLen = 0;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05303811 pAddBssParams->staContext.shortPreambleSupported =
3812 psessionEntry->beaconParams.fShortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 pAddBssParams->staContext.updateSta = updateEntry;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303814
Abhishek Singh525045c2014-12-15 17:18:45 +05303815 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303816 " shortPreambleSupported: %d"),
3817 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
3818 pAddBssParams->staContext.shortPreambleSupported);
3819
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003820 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 {
3822 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3823 pAddBssParams->staContext.htCapable = 1;
3824 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3825 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05303826 limLog(pMac, LOG1,FL("StaContext htCapable: %d greenFieldCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303827 "lsigTxopProtection: %d"), pAddBssParams->staContext.htCapable,
3828 pAddBssParams->staContext.greenFieldCapable,
3829 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003830#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05303831 if (psessionEntry->vhtCapability &&
3832 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003833 {
3834 pAddBssParams->staContext.vhtCapable = 1;
3835 if ((pAssocRsp->VHTCaps.suBeamFormerCap ||
3836 pAssocRsp->VHTCaps.muBeamformerCap) &&
3837 psessionEntry->txBFIniFeatureEnabled)
3838 {
3839 pAddBssParams->staContext.vhtTxBFCapable = 1;
3840 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303841 if (pAssocRsp->VHTCaps.muBeamformerCap &&
3842 psessionEntry->txMuBformee )
3843 {
3844 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
3845 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
3846 /* Dont allow any other MuBf session as concurrency
3847 * is not supported
3848 */
3849 pMac->isMuBfsessionexist = TRUE;
3850 }
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003851 }
3852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3854 (chanWidthSupp) )
3855 {
3856 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003857#ifdef WLAN_FEATURE_11AC
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003858 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003859 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003860 pAddBssParams->staContext.vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth; //pMac->lim.apChanWidth;
3861 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303862 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303863 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
3864 pAddBssParams->staContext.vhtCapable,
3865 pAddBssParams->staContext.vhtTxChannelWidthSet,
3866 pAddBssParams->staContext.vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003867#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 }
3869 else
3870 {
3871 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3872 }
3873 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pAssocRsp->HTCaps.mimoPowerSave;
3874 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3875 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3876 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3877 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003878 /*
3879 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3880 * if they are set then we will use what ever Assoc response coming
3881 * from AP supports. If these values are set as 0 in ini file then
3882 * we will hardcode this values to 0.
3883 */
3884 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3885 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3886 &shortGi20MhzSupport)))
3887 {
3888 if (VOS_TRUE == shortGi20MhzSupport)
3889 {
3890 pAddBssParams->staContext.fShortGI20Mhz =
3891 (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3892 }
3893 else
3894 {
3895 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3896 }
3897 }
3898 else
3899 {
3900 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3901 "CFG,setting value to default"));)
3902 pAddBssParams->staContext.fShortGI20Mhz =
3903 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3904 }
3905
3906 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3907 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3908 &shortGi40MhzSupport)))
3909 {
3910 if (VOS_TRUE == shortGi40MhzSupport)
3911 {
3912 pAddBssParams->staContext.fShortGI40Mhz =
3913 (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3914 }
3915 else
3916 {
3917 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3918 }
3919 }
3920 else
3921 {
3922 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3923 "CFG,setting value to default"));)
3924 pAddBssParams->staContext.fShortGI40Mhz =
3925 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3926 }
3927
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05303929 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003930 {
3931 pAddBssParams->staContext.htLdpcCapable = 0;
3932 pAddBssParams->staContext.vhtLdpcCapable = 0;
3933 }
3934 else
3935 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05303936 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
3937 pAddBssParams->staContext.htLdpcCapable =
3938 (tANI_U8)pAssocRsp->HTCaps.advCodingCap;
3939 else
3940 pAddBssParams->staContext.htLdpcCapable = 0;
3941 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
3942 pAddBssParams->staContext.vhtLdpcCapable =
3943 (tANI_U8)pAssocRsp->VHTCaps.ldpcCodingCap;
3944 else
3945 pAddBssParams->staContext.vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003946 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003947
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 if( pBeaconStruct->HTInfo.present )
3949 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303950
Abhishek Singh525045c2014-12-15 17:18:45 +05303951 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303952 " delBASupport: %d maxAmsduSize: %d"),
3953 pAddBssParams->staContext.txChannelWidthSet,
3954 pAddBssParams->staContext.mimoPS,
3955 pAddBssParams->staContext.delBASupport,
3956 pAddBssParams->staContext.maxAmsduSize);
3957
Abhishek Singh525045c2014-12-15 17:18:45 +05303958 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303959 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
3960 pAddBssParams->staContext.fDsssCckMode40Mhz,
3961 pAddBssParams->staContext.fShortGI20Mhz);
3962
Abhishek Singh525045c2014-12-15 17:18:45 +05303963 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303964 "htLdpcCapable: %d vhtLdpcCapable: %d"),
3965 pAddBssParams->staContext.fShortGI40Mhz,
3966 pAddBssParams->staContext.maxAmpduSize,
3967 pAddBssParams->staContext.htLdpcCapable,
3968 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 }
3970
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303971 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3972 if ((psessionEntry->limWmeEnabled && (pAssocRsp->wmeEdcaPresent || pAddBssParams->htCapable)) ||
3973 (psessionEntry->limQosEnabled && (pAssocRsp->edcaPresent || pAddBssParams->htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 pAddBssParams->staContext.wmmEnabled = 1;
3975 else
3976 pAddBssParams->staContext.wmmEnabled = 0;
3977
3978 //Update the rates
3979
3980 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3981 if (pStaDs != NULL)
3982 {
3983 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303984 vos_mem_copy((tANI_U8*)&pAddBssParams->staContext.supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 (tANI_U8*)&pStaDs->supportedRates,
3986 sizeof(tSirSupportedRates));
3987 }
3988 else
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003989 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003990
3991 }
3992
3993 //Disable BA. It will be set as part of ADDBA negotiation.
3994 for( i = 0; i < STACFG_MAX_TC; i++ )
3995 {
3996 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3997 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3998 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3999 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
4000 }
4001
4002 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4003
4004#if defined WLAN_FEATURE_VOWIFI
4005 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05304006 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304007 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07004008#endif
4009 // FIXME_GEN4 - Any other value that can be used for initialization?
4010 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4011 pAddBssParams->respReqd = true;
4012
4013 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4014
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
4016 {
4017 pAddBssParams->staContext.p2pCapableSta = 1;
4018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004019
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004020 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021
4022#if defined WLAN_FEATURE_VOWIFI_11R
4023 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05304024 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304025 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004026#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 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
4038 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
4039 else
4040 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Abhishek Singh2fefebd2016-01-13 14:37:49 +05304041
Jeff Johnsone7245742012-09-05 17:12:55 -07004042 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004043
Abhishek Singh525045c2014-12-15 17:18:45 +05304044 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304045 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
4046 pAddBssParams->staContext.encryptType,
4047 pAddBssParams->staContext.p2pCapableSta);
4048
Abhishek Singh525045c2014-12-15 17:18:45 +05304049 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304050 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
4051 pAddBssParams->halPersona, psessionEntry->limMlmState);
4052
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 //we need to defer the message until we get the response back from HAL.
4054 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4055
4056 msgQ.type = WDA_ADD_BSS_REQ;
4057 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4058 msgQ.reserved = 0;
4059 msgQ.bodyptr = pAddBssParams;
4060 msgQ.bodyval = 0;
4061
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05304062 limLog( pMac, LOG1, FL("SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
4063 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004064 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004065
4066 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4067 if( eSIR_SUCCESS != retCode)
4068 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004069 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304070 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004071 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 retCode );
4073 goto returnFailure;
4074
4075 }
4076 else
4077 return retCode;
4078
4079 returnFailure:
4080 // Clean-up will be done by the caller...
4081 return retCode;
4082}
4083
4084
4085
4086
4087tSirRetStatus limStaSendAddBssPreAssoc( tpAniSirGlobal pMac, tANI_U8 updateEntry, tpPESession psessionEntry)
4088{
4089 tSirMsgQ msgQ;
4090 tpAddBssParams pAddBssParams = NULL;
4091 tANI_U32 retCode;
4092 tANI_U8 i;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004093 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07004095 tANI_U32 shortGi20MhzSupport;
4096 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 tpSirBssDescription bssDescription = &psessionEntry->pLimJoinReq->bssDescription;
4098
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304099 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
4100 if (NULL == pBeaconStruct)
Jeff Johnson32d95a32012-09-10 13:15:23 -07004101 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304102 limLog(pMac, LOGE, FL("Unable to allocate memory during ADD_BSS") );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004103 return eSIR_MEM_ALLOC_FAILED;
4104 }
4105
Jeff Johnson295189b2012-06-20 16:38:30 -07004106
4107 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304108 pAddBssParams = vos_mem_malloc(sizeof(tAddBssParams));
4109 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 {
4111 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304112 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 retCode = eSIR_MEM_ALLOC_FAILED;
4114 goto returnFailure;
4115 }
4116
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304117 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004118
4119
4120 limExtractApCapabilities( pMac,
4121 (tANI_U8 *) bssDescription->ieFields,
Abhishek Singhbad2b322016-10-21 11:22:33 +05304122 GET_IE_LEN_IN_BSS(bssDescription->length),
Jeff Johnson32d95a32012-09-10 13:15:23 -07004123 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07004124
4125 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson32d95a32012-09-10 13:15:23 -07004126 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304127 vos_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
4128 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004129
4130 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304131 vos_mem_copy(pAddBssParams->selfMacAddr,
4132 psessionEntry->selfMacAddr,
4133 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304134 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
4135 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004136
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304137 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
4138 MAC_ADDR_ARRAY(pAddBssParams->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304140 * top of an already established Infra link. This lead to issues in
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 * concurrent data transfer.
4142 */
4143
4144 pAddBssParams->bssType = psessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
4145 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
4146
4147 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
4148
Jeff Johnson32d95a32012-09-10 13:15:23 -07004149 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 pAddBssParams->updateBss = updateEntry;
4151
4152
Jeff Johnson32d95a32012-09-10 13:15:23 -07004153 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
4154 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
4155 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
4156 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -07004157
4158
Jeff Johnson32d95a32012-09-10 13:15:23 -07004159 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304160 vos_mem_copy(pAddBssParams->rateSet.rate,
4161 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07004162
4163 pAddBssParams->nwType = bssDescription->nwType;
4164
Jeff Johnson32d95a32012-09-10 13:15:23 -07004165 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
4167 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
4168 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304169 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
Jeff Johnson295189b2012-06-20 16:38:30 -07004170
Abhishek Singh525045c2014-12-15 17:18:45 +05304171 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304172 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
4173 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
4174
Abhishek Singh525045c2014-12-15 17:18:45 +05304175 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304176 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
4177 pAddBssParams->cfParamSet.cfpMaxDuration,
4178 pAddBssParams->cfParamSet.cfpDurRemaining,
4179 pAddBssParams->rateSet.numRates);
4180
Abhishek Singh525045c2014-12-15 17:18:45 +05304181 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304182 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
4183 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
4184 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
4185 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 // Use the advertised capabilities from the received beacon/PR
Jeff Johnson32d95a32012-09-10 13:15:23 -07004187 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004189 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05304190 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004191 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004193 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
4194 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07004195
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004197 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 (chanWidthSupp) )
4199 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004200 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
4201 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 }
4203 else
4204 {
4205 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004206 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004208 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
4209 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
4210 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304211
Abhishek Singh525045c2014-12-15 17:18:45 +05304212 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304213 "txChannelWidthSet: %d currentExtChannel: %d "),
4214 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
4215 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
4216
Abhishek Singh525045c2014-12-15 17:18:45 +05304217 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304218 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
4219 pAddBssParams->llnNonGFCoexist,
4220 pAddBssParams->fLsigTXOPProtectionFullSupport,
4221 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 }
4223 }
4224
4225 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05304226 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304227 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004228#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304229 if (psessionEntry->vhtCapability &&
4230 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Jeff Johnsone7245742012-09-05 17:12:55 -07004231 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004232 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
4233 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004234 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
4235 pAddBssParams->currentOperChannel,
4236 pAddBssParams->currentExtChannel,
4237 psessionEntry->apCenterChan,
4238 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004239 }
4240 else
4241 {
4242 pAddBssParams->vhtCapable = 0;
4243 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304244 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304245 "currentExtChannel %d"),pAddBssParams->vhtCapable,
4246 pAddBssParams->vhtTxChannelWidthSet,
4247 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004248#endif
4249
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 // Populate the STA-related parameters here
4251 // Note that the STA here refers to the AP
4252 {
4253 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
4254
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304255 vos_mem_copy(pAddBssParams->staContext.bssId,
4256 bssDescription->bssId,
4257 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
4259
4260 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
4261 pAddBssParams->staContext.uAPSD = 0;
4262 pAddBssParams->staContext.maxSPLen = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004263 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 pAddBssParams->staContext.updateSta = updateEntry;
4265
Abhishek Singh525045c2014-12-15 17:18:45 +05304266 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304267 " shortPreambleSupported: %d"),
4268 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
4269 pAddBssParams->staContext.shortPreambleSupported);
4270
Jeff Johnson32d95a32012-09-10 13:15:23 -07004271 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 {
4273 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
4274 pAddBssParams->staContext.htCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004275 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
4276 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05304277 limLog(pMac, LOG1, FL("StaContext htCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304278 "greenFieldCapable: %d lsigTxopProtection: %d"),
4279 pAddBssParams->staContext.htCapable,
4280 pAddBssParams->staContext.greenFieldCapable,
4281 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004282#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304283 if (psessionEntry->vhtCapability &&
4284 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004285 {
4286 pAddBssParams->staContext.vhtCapable = 1;
4287 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
4288 pBeaconStruct->VHTCaps.muBeamformerCap) &&
4289 psessionEntry->txBFIniFeatureEnabled )
4290 {
4291 pAddBssParams->staContext.vhtTxBFCapable = 1;
4292 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05304293 if (pBeaconStruct->VHTCaps.muBeamformerCap &&
4294 psessionEntry->txMuBformee )
4295 {
4296 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
4297 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
4298 /* Dont allow any other MuBf session as concurrency
4299 * is not supported
4300 */
4301 pMac->isMuBfsessionexist = TRUE;
4302 }
4303
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004304 }
4305#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004306 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 (chanWidthSupp) )
4308 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004309 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004310#ifdef WLAN_FEATURE_11AC
4311 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07004312 {
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004313 pAddBssParams->staContext.vhtTxChannelWidthSet =
4314 pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -07004315 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304316 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304317 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
4318 pAddBssParams->staContext.vhtCapable,
4319 pAddBssParams->staContext.vhtTxChannelWidthSet,
4320 pAddBssParams->staContext.vhtTxBFCapable);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004321#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 }
4323 else
4324 {
4325 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4326 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004327 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
4328 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
4329 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
4330 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
4331 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07004332 /*
4333 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
4334 * if they are set then we will use what ever Beacon coming from AP
4335 * supports. If these values are set as 0 in ini file then
4336 * we will hardcode this values to 0.
4337 */
4338 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4339 (pMac, WNI_CFG_SHORT_GI_20MHZ,
4340 &shortGi20MhzSupport)))
4341 {
4342 if (VOS_TRUE == shortGi20MhzSupport)
4343 {
4344 pAddBssParams->staContext.fShortGI20Mhz =
4345 (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
4346 }
4347 else
4348 {
4349 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
4350 }
4351 }
4352 else
4353 {
4354 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
4355 "CFG,setting value to default"));)
4356 pAddBssParams->staContext.fShortGI20Mhz =
4357 WNI_CFG_SHORT_GI_20MHZ_STADEF;
4358 }
4359
4360 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4361 (pMac, WNI_CFG_SHORT_GI_40MHZ,
4362 &shortGi40MhzSupport)))
4363 {
4364 if (VOS_TRUE == shortGi40MhzSupport)
4365 {
4366 pAddBssParams->staContext.fShortGI40Mhz =
4367 (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
4368 }
4369 else
4370 {
4371 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
4372 }
4373 }
4374 else
4375 {
4376 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
4377 "CFG,setting value to default"));)
4378 pAddBssParams->staContext.fShortGI40Mhz =
4379 WNI_CFG_SHORT_GI_40MHZ_STADEF;
4380 }
4381
Jeff Johnson32d95a32012-09-10 13:15:23 -07004382 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05304383 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08004384 {
4385 pAddBssParams->staContext.htLdpcCapable = 0;
4386 pAddBssParams->staContext.vhtLdpcCapable = 0;
4387 }
4388 else
4389 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05304390 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
4391 pAddBssParams->staContext.htLdpcCapable =
4392 (tANI_U8)pBeaconStruct->HTCaps.advCodingCap;
4393 else
4394 pAddBssParams->staContext.htLdpcCapable = 0;
4395 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
4396 pAddBssParams->staContext.vhtLdpcCapable =
4397 (tANI_U8)pBeaconStruct->VHTCaps.ldpcCodingCap;
4398 else
4399 pAddBssParams->staContext.vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08004400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004401
Jeff Johnson32d95a32012-09-10 13:15:23 -07004402 if( pBeaconStruct->HTInfo.present )
4403 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singh525045c2014-12-15 17:18:45 +05304404 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304405 " delBASupport: %d maxAmsduSize: %d"),
4406 pAddBssParams->staContext.txChannelWidthSet,
4407 pAddBssParams->staContext.mimoPS,
4408 pAddBssParams->staContext.delBASupport,
4409 pAddBssParams->staContext.maxAmsduSize);
4410
Abhishek Singh525045c2014-12-15 17:18:45 +05304411 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304412 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
4413 pAddBssParams->staContext.fDsssCckMode40Mhz,
4414 pAddBssParams->staContext.fShortGI20Mhz);
4415
Abhishek Singh525045c2014-12-15 17:18:45 +05304416 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304417 "htLdpcCapable: %d vhtLdpcCapable: %d"),
4418 pAddBssParams->staContext.fShortGI40Mhz,
4419 pAddBssParams->staContext.maxAmpduSize,
4420 pAddBssParams->staContext.htLdpcCapable,
4421 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 }
4423
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05304424 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
4425 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent || pAddBssParams->staContext.htCapable)) ||
4426 (psessionEntry->limQosEnabled && (pBeaconStruct->edcaPresent || pAddBssParams->staContext.htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 pAddBssParams->staContext.wmmEnabled = 1;
4428 else
4429 pAddBssParams->staContext.wmmEnabled = 0;
4430
4431 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -07004432#ifdef WLAN_FEATURE_11AC
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004433 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004434 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry,
4435 &pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -07004436#else
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004437 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004438 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004439#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,psessionEntry);
4441
4442 }
4443
4444
4445 //Disable BA. It will be set as part of ADDBA negotiation.
4446 for( i = 0; i < STACFG_MAX_TC; i++ )
4447 {
4448 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
4449 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
4450 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
4451 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
4452 }
4453
4454 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4455
4456#if defined WLAN_FEATURE_VOWIFI
4457 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05304458 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304459 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07004460#endif
4461
4462 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4463 pAddBssParams->respReqd = true;
4464
4465 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4466 pAddBssParams->sessionId = psessionEntry->peSessionId;
4467
4468 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4469
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004470 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004471
4472#if defined WLAN_FEATURE_VOWIFI_11R
4473 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05304474 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304475 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004476#endif
4477
Chet Lanctot186b5732013-03-18 10:26:30 -07004478#ifdef WLAN_FEATURE_11W
4479 if (psessionEntry->limRmfEnabled)
4480 {
4481 pAddBssParams->rmfEnabled = 1;
4482 pAddBssParams->staContext.rmfEnabled = 1;
4483 }
4484#endif
4485
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 // Set a new state for MLME
4487
4488 //pMac->lim.gLimMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4489 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4490
Jeff Johnsone7245742012-09-05 17:12:55 -07004491 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004492
Abhishek Singh525045c2014-12-15 17:18:45 +05304493 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304494 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
4495 pAddBssParams->staContext.encryptType,
4496 pAddBssParams->staContext.p2pCapableSta);
4497
Abhishek Singh525045c2014-12-15 17:18:45 +05304498 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304499 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
4500 pAddBssParams->halPersona, psessionEntry->limMlmState);
4501
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 //we need to defer the message until we get the response back from HAL.
4503 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4504
4505 msgQ.type = WDA_ADD_BSS_REQ;
4506 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4507 msgQ.reserved = 0;
4508 msgQ.bodyptr = pAddBssParams;
4509 msgQ.bodyval = 0;
4510
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05304511 limLog( pMac, LOG1, FL( "SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
4512 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004513 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004514
4515 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4516 if( eSIR_SUCCESS != retCode)
4517 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004518 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304519 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004520 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 retCode );
4522 goto returnFailure;
4523
4524 }
4525 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07004526 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304527 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 return retCode;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004530
4531 returnFailure:
4532 // Clean-up will be done by the caller...
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304533 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 return retCode;
4535}
4536
4537
4538
4539
4540
Jeff Johnson295189b2012-06-20 16:38:30 -07004541
4542/** -------------------------------------------------------------
4543\fn limPrepareAndSendDelStaCnf
4544\brief deletes DPH entry
4545 changes the MLM mode for station.
4546 calls limSendDelStaCnf
4547\param tpAniSirGlobal pMac
4548\param tpDphHashNode pStaDs
4549\return none
4550 -------------------------------------------------------------*/
4551
4552
4553void
4554limPrepareAndSendDelStaCnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tSirResultCodes statusCode,tpPESession psessionEntry)
4555{
4556 tANI_U16 staDsAssocId = 0;
4557 tSirMacAddr staDsAddr;
4558 tLimMlmStaContext mlmStaContext;
4559
4560 if(pStaDs == NULL)
4561 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004562 PELOGW(limLog(pMac, LOGW, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 return;
4564 }
4565 staDsAssocId = pStaDs->assocId;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304566 vos_mem_copy((tANI_U8 *)staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 pStaDs->staAddr,
4568 sizeof(tSirMacAddr));
4569
4570 mlmStaContext = pStaDs->mlmStaContext;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304571 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4572 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 {
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304574 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 }
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304576 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
4577
4578 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4579 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 {
4581 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304582 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
4583 psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 limSendDelStaCnf(pMac, staDsAddr, staDsAssocId, mlmStaContext, statusCode,psessionEntry);
4586}
4587
4588/** -------------------------------------------------------------
4589\fn limGetStaRateMode
4590\brief Gets the Station Rate Mode.
4591\param tANI_U8 dot11Mode
4592\return none
4593 -------------------------------------------------------------*/
4594tStaRateMode limGetStaRateMode(tANI_U8 dot11Mode)
4595{
4596 switch(dot11Mode)
4597 {
4598 case WNI_CFG_DOT11_MODE_11A:
4599 return eSTA_11a;
4600 case WNI_CFG_DOT11_MODE_11B:
4601 return eSTA_11b;
4602 case WNI_CFG_DOT11_MODE_11G:
4603 return eSTA_11bg;
4604 case WNI_CFG_DOT11_MODE_11N:
4605 return eSTA_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07004606#ifdef WLAN_FEATURE_11AC
4607 case WNI_CFG_DOT11_MODE_11AC:
4608 return eSTA_11ac;
4609#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 case WNI_CFG_DOT11_MODE_ALL:
4611 default:
4612 return eSTA_11n;
4613
4614 }
4615}
4616
4617/** -------------------------------------------------------------
4618\fn limInitPreAuthTimerTable
4619\brief Initialize the Pre Auth Tanle and creates the timer for
4620 each node for the timeout value got from cfg.
4621\param tpAniSirGlobal pMac
4622\param tpLimPreAuthTable pPreAuthTimerTable
4623\return none
4624 -------------------------------------------------------------*/
4625void limInitPreAuthTimerTable(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4626{
4627 tANI_U32 cfgValue;
4628 tANI_U32 authNodeIdx;
4629 tpLimPreAuthNode pAuthNode = pPreAuthTimerTable->pTable;
4630
4631 // Get AUTH_RSP Timers value
4632
4633 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4634 &cfgValue) != eSIR_SUCCESS)
4635 {
4636 /*
4637 ** Could not get AUTH_RSP timeout value
4638 ** from CFG. Log error.
4639 **/
4640 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004641 FL("could not retrieve AUTH_RSP timeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 return;
4643 }
4644
4645 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4646 for(authNodeIdx=0; authNodeIdx<pPreAuthTimerTable->numEntry; authNodeIdx++, pAuthNode++)
4647 {
4648 if (tx_timer_create(&pAuthNode->timer,
4649 "AUTH RESPONSE TIMEOUT",
4650 limAuthResponseTimerHandler,
4651 authNodeIdx,
4652 cfgValue,
4653 0,
4654 TX_NO_ACTIVATE) != TX_SUCCESS)
4655 {
4656 // Cannot create timer. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004657 limLog(pMac, LOGP, FL("Cannot create Auth Rsp timer of Index :%d."), authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 return;
4659 }
4660 pAuthNode->authNodeIdx = (tANI_U8)authNodeIdx;
4661 pAuthNode->fFree = 1;
4662 }
4663
4664}
4665
4666/** -------------------------------------------------------------
4667\fn limAcquireFreePreAuthNode
4668\brief Retrives a free Pre Auth node from Pre Auth Table.
4669\param tpAniSirGlobal pMac
4670\param tpLimPreAuthTable pPreAuthTimerTable
4671\return none
4672 -------------------------------------------------------------*/
4673tLimPreAuthNode * limAcquireFreePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4674{
4675 tANI_U32 i;
4676 tLimPreAuthNode *pTempNode = pPreAuthTimerTable->pTable;
4677 for (i=0; i<pPreAuthTimerTable->numEntry; i++,pTempNode++)
4678 {
4679 if (pTempNode->fFree == 1)
4680 {
4681 pTempNode->fFree = 0;
4682 return pTempNode;
4683 }
4684 }
4685
4686 return NULL;
4687}
4688
4689/** -------------------------------------------------------------
4690\fn limGetPreAuthNodeFromIndex
4691\brief Depending on the Index this retrives the pre auth node.
4692\param tpAniSirGlobal pMac
4693\param tpLimPreAuthTable pAuthTable
4694\param tANI_U32 authNodeIdx
4695\return none
4696 -------------------------------------------------------------*/
4697tLimPreAuthNode * limGetPreAuthNodeFromIndex(tpAniSirGlobal pMac,
4698 tpLimPreAuthTable pAuthTable, tANI_U32 authNodeIdx)
4699{
4700 if ((authNodeIdx >= pAuthTable->numEntry) || (pAuthTable->pTable == NULL))
4701 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004702 limLog(pMac, LOGE, FL("Invalid Auth Timer Index : %d NumEntry : %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 authNodeIdx, pAuthTable->numEntry);
4704 return NULL;
4705 }
4706
4707 return pAuthTable->pTable + authNodeIdx;
4708}
4709
4710/* Util API to check if the channels supported by STA is within range */
4711tSirRetStatus limIsDot11hSupportedChannelsValid(tpAniSirGlobal pMac, tSirAssocReq *assoc)
4712{
4713 /*
4714 * Allow all the stations to join with us.
4715 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4716 * as an input into an algorithm used to select a new channel for the BSS.
4717 * The specification of the algorithm is beyond the scope of this amendment.
4718 */
4719
4720 return (eSIR_SUCCESS);
4721}
4722
4723/* Util API to check if the txpower supported by STA is within range */
4724tSirRetStatus limIsDot11hPowerCapabilitiesInRange(tpAniSirGlobal pMac, tSirAssocReq *assoc,tpPESession psessionEntry)
4725{
4726 tPowerdBm localMaxTxPower;
4727 tANI_U32 localPwrConstraint;
4728
4729 localMaxTxPower = cfgGetRegulatoryMaxTransmitPower(pMac, psessionEntry->currentOperChannel);
4730
4731 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004732 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 return eSIR_FAILURE;
4734 }
4735 localMaxTxPower -= (tPowerdBm)localPwrConstraint;
4736
4737 /**
4738 * The min Tx Power of the associating station should not be greater than (regulatory
4739 * max tx power - local power constraint configured on AP).
4740 */
4741 if(assoc->powerCapability.minTxPower > localMaxTxPower)
4742 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004743 limLog(pMac, LOGW, FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 assoc->powerCapability.minTxPower, localMaxTxPower);
4745 return (eSIR_FAILURE);
4746 }
4747
4748 return (eSIR_SUCCESS);
4749}
4750
4751/** -------------------------------------------------------------
4752\fn limFillRxHighestSupportedRate
4753\brief Fills in the Rx Highest Supported Data Rate field from
4754\ the 'supported MCS set' field in HT capability element.
4755\param tpAniSirGlobal pMac
4756\param tpSirSupportedRates pRates
4757\param tANI_U8* pSupportedMCSSet
4758\return none
4759 -------------------------------------------------------------*/
4760void limFillRxHighestSupportedRate(tpAniSirGlobal pMac, tANI_U16 *rxHighestRate, tANI_U8* pSupportedMCSSet)
4761{
4762 tSirMacRxHighestSupportRate *pRxHighestRate;
4763 tANI_U8 *pBuf;
4764 tANI_U16 rate=0;
4765
4766 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4767 rate = limGetU16(pBuf);
4768
4769 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4770 *rxHighestRate = pRxHighestRate->rate;
4771
4772 return;
4773}
Chet Lanctot186b5732013-03-18 10:26:30 -07004774
4775#ifdef WLAN_FEATURE_11W
4776/** -------------------------------------------------------------
4777\fn limSendSmeUnprotectedMgmtFrameInd
4778\brief Forwards the unprotected management frame to SME.
4779\param tpAniSirGlobal pMac
4780\param frameType - 802.11 frame type
4781\param frame - frame buffer
4782\param sessionId - id for the current session
4783\param psessionEntry - PE session context
4784\return none
4785 -------------------------------------------------------------*/
4786void limSendSmeUnprotectedMgmtFrameInd(
4787 tpAniSirGlobal pMac, tANI_U8 frameType,
4788 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
4789 tpPESession psessionEntry)
4790{
4791 tSirMsgQ mmhMsg;
4792 tSirSmeUnprotMgmtFrameInd * pSirSmeMgmtFrame = NULL;
4793 tANI_U16 length;
4794
4795 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4796
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304797 pSirSmeMgmtFrame = vos_mem_malloc(length);
4798 if (NULL == pSirSmeMgmtFrame)
Chet Lanctot186b5732013-03-18 10:26:30 -07004799 {
4800 limLog(pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304801 FL("AllocateMemory failed for tSirSmeUnprotectedMgmtFrameInd"));
Chet Lanctot186b5732013-03-18 10:26:30 -07004802 return;
4803 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304804 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Chet Lanctot186b5732013-03-18 10:26:30 -07004805
4806 pSirSmeMgmtFrame->sessionId = sessionId;
4807 pSirSmeMgmtFrame->frameType = frameType;
4808
4809 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
4810 pSirSmeMgmtFrame->frameLen = frameLen;
4811
4812 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4813 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4814 mmhMsg.bodyval = 0;
4815
4816 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4817 return;
4818}
4819#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004820
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004821#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004822/** -------------------------------------------------------------
4823\fn limSendSmeTsmIEInd
4824\brief Forwards the TSM IE information to SME.
4825\param tpAniSirGlobal pMac
4826\param psessionEntry - PE session context
4827\param tid - traffic id
4828\param state - tsm state (enabled/disabled)
4829\param measurementInterval - measurement interval
4830\return none
4831 -------------------------------------------------------------*/
4832void limSendSmeTsmIEInd(tpAniSirGlobal pMac, tpPESession psessionEntry,
4833 tANI_U8 tid, tANI_U8 state, tANI_U16 measInterval)
4834{
4835 tSirMsgQ mmhMsg;
4836 tpSirSmeTsmIEInd pSirSmeTsmIeInd = NULL;
4837
4838 if (!pMac || !psessionEntry)
4839 {
4840 return;
4841 }
4842 pSirSmeTsmIeInd = vos_mem_malloc(sizeof(tSirSmeTsmIEInd));
4843 if (NULL == pSirSmeTsmIeInd)
4844 {
4845 limLog(pMac, LOGP,
4846 FL("AllocateMemory failed for tSirSmeTsmIEInd"));
4847 return;
4848 }
4849 vos_mem_set((void*)pSirSmeTsmIeInd, sizeof(tSirSmeTsmIEInd), 0);
4850
4851 pSirSmeTsmIeInd->sessionId = psessionEntry->smeSessionId;
4852 pSirSmeTsmIeInd->tsmIe.tsid = tid;
4853 pSirSmeTsmIeInd->tsmIe.state= state;
4854 pSirSmeTsmIeInd->tsmIe.msmt_interval= measInterval;
4855
4856 mmhMsg.type = eWNI_SME_TSM_IE_IND;
4857 mmhMsg.bodyptr = pSirSmeTsmIeInd;
4858 mmhMsg.bodyval = 0;
4859
4860 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4861 return;
4862}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004863#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004864
4865