blob: b3ce7c616203f1f7637f788a4499c806041b5df9 [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 }
1098 }
1099 else
1100 {
1101 limSendAssocRspMgmtFrame(pMac,
1102 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
1103 1,
1104 peerAddr,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301105 subType, 0,psessionEntry, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 // Log error
1107 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001108 FL("received Re/Assoc req when max associated STAs reached from "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 limPrintMacAddr(pMac, peerAddr, LOGW);
1110 limSendSmeMaxAssocExceededNtf(pMac, peerAddr, psessionEntry->smeSessionId);
1111 }
1112} /*** end limRejectAssociation() ***/
1113
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115/** -------------------------------------------------------------
1116\fn limDecideApProtectionOnHt20Delete
1117\brief protection related function while HT20 station is getting deleted.
1118\param tpAniSirGlobal pMac
1119\param tpDphHashNode pStaDs
1120\param tpUpdateBeaconParams pBeaconParams
1121\return None
1122 -------------------------------------------------------------*/
1123static void
1124limDecideApProtectionOnHt20Delete(tpAniSirGlobal pMac,
1125 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1126{
1127 tANI_U32 i = 0;
1128 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT 20 STA is disassociated. Addr is "),
1129 psessionEntry->gLimHt20Params.numSta);
1130 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1131 if (psessionEntry->gLimHt20Params.numSta > 0)
1132 {
1133 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1134 {
1135 if (psessionEntry->protStaCache[i].active)
1136 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301137 if (vos_mem_compare(psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 pStaDs->staAddr, sizeof(tSirMacAddr)))
1139 {
1140 psessionEntry->gLimHt20Params.numSta--;
1141 psessionEntry->protStaCache[i].active = false;
1142 break;
1143 }
1144 }
1145 }
1146 }
1147
1148 if (psessionEntry->gLimHt20Params.numSta == 0)
1149 {
1150 // disable protection
Nirav Shahbc35fb72013-12-12 18:14:06 +05301151 limLog(pMac, LOG1, FL("No 11B STA exists, PESessionID %d"),
1152 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
1154 }
1155}
1156/** -------------------------------------------------------------
1157\fn limDecideApProtectionOnDelete
1158\brief Decides about protection related settings when a station is getting deleted.
1159\param tpAniSirGlobal pMac
1160\param tpDphHashNode pStaDs
1161\param tpUpdateBeaconParams pBeaconParams
1162\return None
1163 -------------------------------------------------------------*/
1164void
1165limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
1166 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1167{
1168 tANI_U32 phyMode;
1169 tHalBitVal erpEnabled = eHAL_CLEAR;
1170 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1171 tANI_U32 i;
1172
1173 if(NULL == pStaDs)
1174 return;
1175
1176 limGetRfBand(pMac, &rfBand, psessionEntry);
1177 if(SIR_BAND_5_GHZ == rfBand)
1178 {
1179 //we are HT. if we are 11A, then protection is not required.
Jeff Johnsone7245742012-09-05 17:12:55 -07001180 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 {
1182 //we are HT and 11A station is leaving.
1183 //protection consideration required.
1184 //HT station leaving ==> this case is commonly handled between both the bands below.
1185 if((psessionEntry->beaconParams.llaCoexist) &&
1186 (false == pStaDs->mlmStaContext.htCapability))
1187 {
1188 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11A STA is disassociated. Addr is "),
1189 psessionEntry->gLim11aParams.numSta);
1190 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1191 if (psessionEntry->gLim11aParams.numSta > 0)
1192 {
1193 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1194 {
1195 if (psessionEntry->protStaCache[i].active)
1196 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301197 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 pStaDs->staAddr, sizeof(tSirMacAddr)))
1199 {
1200 psessionEntry->gLim11aParams.numSta--;
1201 psessionEntry->protStaCache[i].active = false;
1202 break;
1203 }
1204 }
1205 }
1206 }
1207
1208 if(psessionEntry->gLim11aParams.numSta == 0)
1209 {
1210 // disable protection
1211 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
1212 }
1213 }
1214 }
1215 }
1216 else if(SIR_BAND_2_4_GHZ == rfBand)
1217 {
1218 limGetPhyMode(pMac, &phyMode, psessionEntry);
1219
1220 erpEnabled = pStaDs->erpEnabled;
1221 //we are HT or 11G and 11B station is getting deleted.
1222 if (((phyMode == WNI_CFG_PHY_MODE_11G) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001223 psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 (erpEnabled == eHAL_CLEAR))
1225 {
1226 PELOG1(limLog(pMac, LOG1, FL("(%d) A legacy STA is disassociated. Addr is "),
1227 psessionEntry->gLim11bParams.numSta);
1228 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1229 if (psessionEntry->gLim11bParams.numSta > 0)
1230 {
1231 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1232 {
1233 if (psessionEntry->protStaCache[i].active)
1234 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301235 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 pStaDs->staAddr, sizeof(tSirMacAddr)))
1237 {
1238 psessionEntry->gLim11bParams.numSta--;
1239 psessionEntry->protStaCache[i].active = false;
1240 break;
1241 }
1242 }
1243 }
1244 }
1245
1246 if (psessionEntry->gLim11bParams.numSta == 0)
1247 {
1248 // disable protection
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 limEnable11gProtection(pMac, false, false, pBeaconParams,psessionEntry);
1250 }
1251 }
1252 //(non-11B station is leaving) or (we are not 11G or HT AP)
Jeff Johnsone7245742012-09-05 17:12:55 -07001253 else if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 { //we are HT AP and non-11B station is leaving.
1255
1256 //11g station is leaving
1257 if(!pStaDs->mlmStaContext.htCapability)
1258 {
1259 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11g STA is disassociated. Addr is "),
1260 psessionEntry->gLim11bParams.numSta);
1261 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1262 if (psessionEntry->gLim11gParams.numSta > 0)
1263 {
1264 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1265 {
1266 if (psessionEntry->protStaCache[i].active)
1267 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301268 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 pStaDs->staAddr, sizeof(tSirMacAddr)))
1270 {
1271 psessionEntry->gLim11gParams.numSta--;
1272 psessionEntry->protStaCache[i].active = false;
1273 break;
1274 }
1275 }
1276 }
1277 }
1278
1279 if (psessionEntry->gLim11gParams.numSta == 0)
1280 {
1281 // disable protection
1282 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
1283 }
1284 }
1285 }
1286 }
1287
1288 //LSIG TXOP not supporting staiton leaving. applies to 2.4 as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07001289 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 (true == pStaDs->mlmStaContext.htCapability))
1291 {
1292 //HT non-GF leaving
1293 if(!pStaDs->htGreenfield)
1294 {
1295 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-GF STA is disassociated. Addr is "),
1296 psessionEntry->gLimNonGfParams.numSta);
1297 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1298 if (psessionEntry->gLimNonGfParams.numSta > 0)
1299 {
1300 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1301 {
1302 if (psessionEntry->protStaCache[i].active)
1303 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301304 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 pStaDs->staAddr, sizeof(tSirMacAddr)))
1306 {
1307 psessionEntry->gLimNonGfParams.numSta--;
1308 psessionEntry->protStaCache[i].active = false;
1309 break;
1310 }
1311 }
1312 }
1313 }
1314
1315 if (psessionEntry->gLimNonGfParams.numSta == 0)
1316 {
1317 // disable protection
1318 limEnableHTNonGfProtection(pMac, false, false, pBeaconParams,psessionEntry);
1319 }
1320 }
1321 //HT 20Mhz station leaving.
1322 if(psessionEntry->beaconParams.ht20Coexist &&
1323 (eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet))
1324 {
1325 limDecideApProtectionOnHt20Delete(pMac, pStaDs, pBeaconParams,psessionEntry);
1326 }
1327
1328 if(false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport &&
1329 (false == pStaDs->htLsigTXOPProtection))
1330 {
1331 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is "),
1332 psessionEntry->gLimLsigTxopParams.numSta);
1333 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1334 if (psessionEntry->gLimLsigTxopParams.numSta > 0)
1335 {
1336 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1337 {
1338 if (psessionEntry->protStaCache[i].active)
1339 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301340 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 pStaDs->staAddr, sizeof(tSirMacAddr)))
1342 {
1343 psessionEntry->gLimLsigTxopParams.numSta--;
1344 psessionEntry->protStaCache[i].active = false;
1345 break;
1346 }
1347 }
1348 }
1349 }
1350
1351 if (psessionEntry->gLimLsigTxopParams.numSta == 0)
1352 {
1353 // disable protection
1354 limEnableHTLsigTxopProtection(pMac, true, false, pBeaconParams,psessionEntry);
1355 }
1356 }
1357 }
1358}
1359
Jeff Johnson295189b2012-06-20 16:38:30 -07001360
1361
1362/** -------------------------------------------------------------
1363\fn limDecideShortPreamble
1364\brief Decides about any short preamble reated change because of new station joining.
1365\param tpAniSirGlobal pMac
1366\param tpDphHashNode pStaDs
1367\param tpUpdateBeaconParams pBeaconParams
1368\return None
1369 -------------------------------------------------------------*/
1370void limDecideShortPreamble(tpAniSirGlobal pMac,
1371 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry )
1372{
1373 tANI_U32 i;
1374
1375 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
1376 {
1377 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short preamble STA is disassociated. Addr is "),
1378 psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
1379 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1380 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta > 0)
1381 {
1382 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1383 {
1384 if (psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
1385 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301386 if (vos_mem_compare( psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 pStaDs->staAddr, sizeof(tSirMacAddr)))
1388 {
1389 psessionEntry->gLimNoShortParams.numNonShortPreambleSta--;
1390 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = false;
1391 break;
1392 }
1393 }
1394 }
1395 }
1396
1397 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta == 0)
1398 {
1399 // enable short preamble
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301401 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortParams,
1402 sizeof(tLimNoShortParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 if (limEnableShortPreamble(pMac, true, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001404 PELOGE(limLog(pMac, LOGE, FL("Cannot enable short preamble"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 }
1406 }
1407}
1408
1409/** -------------------------------------------------------------
1410\fn limDecideShortSlot
1411\brief Decides about any short slot time related change because of station leaving the BSS.
1412\param tpAniSirGlobal pMac
1413\param tpDphHashNode pStaDs
1414\return None
1415 -------------------------------------------------------------*/
1416
1417void
1418limDecideShortSlot(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1419 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1420{
1421 tANI_U32 i, val;
1422 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
1423 {
1424 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short slottime STA is disassociated. Addr is "),
1425 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
1426 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1427
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1429 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta> 0)
1430 {
1431 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1432 {
1433 if (psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1434 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301435 if (vos_mem_compare(psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 pStaDs->staAddr, sizeof(tSirMacAddr)))
1437 {
1438 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta--;
1439 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1440 break;
1441 }
1442 }
1443 }
1444 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001445 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001446 {
1447 if (pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta> 0)
1448 {
1449 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1450 {
1451 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1452 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301453 if (vos_mem_compare(pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 pStaDs->staAddr, sizeof(tSirMacAddr)))
1455 {
1456 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta--;
1457 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1458 break;
1459 }
1460 }
1461 }
1462 }
1463 }
1464
1465 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
1466
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1468 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta == 0))
1469 {
1470 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301472 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortSlotParams,
1473 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 // in case of AP set SHORT_SLOT_TIME to enable
1475 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1476 {
1477 pBeaconParams->fShortSlotTime = true;
1478 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001479 psessionEntry->shortSlotTimeSupported = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 }
1481 }
1482 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001483 {
1484 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta == 0)
1485 {
1486 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001487 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301488 vos_mem_set((tANI_U8 *)&pMac->lim.gLimNoShortSlotParams,
1489 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 // in case of AP set SHORT_SLOT_TIME to enable
1491 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1492 {
1493 pBeaconParams->fShortSlotTime = true;
1494 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001495 psessionEntry->shortSlotTimeSupported = true;
1496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 }
1498 }
1499 }
1500}
1501
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001502void
1503limPostReassocFailure(tpAniSirGlobal pMac,
1504 tSirResultCodes resultCode,
1505 tANI_U16 protStatusCode,tpPESession psessionEntry)
1506{
1507 tLimMlmReassocCnf mlmReassocCnf;
1508
1509 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1510 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
1511
1512 // 'Change' timer for future activations
1513 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1514
1515 mlmReassocCnf.resultCode = resultCode;
1516 mlmReassocCnf.protStatusCode = protStatusCode;
1517 /* Update PE session Id */
1518 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1519 limPostSmeMessage(pMac,
1520 LIM_MLM_REASSOC_CNF,
1521 (tANI_U32 *) &mlmReassocCnf);
1522} /*** end limPostReassocFailure() ***/
1523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524/**
1525 * limRestorePreReassocState()
1526 *
1527 *FUNCTION:
1528 * This function is called on STA role whenever Reasociation
1529 * Response with a reject code is received from AP.
1530 *
1531 *LOGIC:
1532 * Reassociation failure timer is stopped, Old (or current) AP's
1533 * context is restored both at Polaris & software
1534 *
1535 *ASSUMPTIONS:
1536 *
1537 *NOTE:
1538 *
1539 * @param pMac - Pointer to Global MAC structure
1540 * @param resultCode - Result code that specifies why Reassociation
1541 * attemp failed
1542 *
1543 * @return None
1544 */
1545
1546void
1547limRestorePreReassocState(tpAniSirGlobal pMac,
1548 tSirResultCodes resultCode,
1549 tANI_U16 protStatusCode,tpPESession psessionEntry)
1550{
Jeff Johnsone7245742012-09-05 17:12:55 -07001551 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 tLimMlmReassocCnf mlmReassocCnf;
1553
Abhishek Singhdcbd8272014-01-09 14:16:01 +05301554 limLog(pMac, LOG1, FL("sessionid: %d protStatusCode: %d resultCode: %d"),
1555 psessionEntry->smeSessionId, protStatusCode, resultCode);
1556
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001558 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001559
1560 // 'Change' timer for future activations
1561 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1562
1563 // Update BSSID at CFG database
1564 #if 0
1565 if (cfgSetStr(pMac, WNI_CFG_BSSID,
1566 pMac->lim.gLimCurrentBssId,
1567 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1568 {
1569 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001570 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 return;
1572 }
Madan Mohan Koyyalamudi70322d52012-10-18 20:07:33 -07001573 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001574
1575 // chanNum = pMac->lim.gLimCurrentChannelId;
1576
1577 /* To support BT-AMP */
1578 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07001579 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001580
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001582
1583 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1584
1585 mlmReassocCnf.resultCode = resultCode;
1586 mlmReassocCnf.protStatusCode = protStatusCode;
1587 /* Update PE session Id */
1588 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1589 limPostSmeMessage(pMac,
1590 LIM_MLM_REASSOC_CNF,
1591 (tANI_U32 *) &mlmReassocCnf);
1592} /*** end limRestorePreReassocState() ***/
1593
1594
1595
1596/**
1597 * limIsReassocInProgress()
1598 *
1599 *FUNCTION:
1600 * This function is called to see if STA is in wt-reassoc-rsp state.
1601 *
1602 *LOGIC:
1603 *
1604 *ASSUMPTIONS:
1605 *
1606 *NOTE:
1607 *
1608 * @param pMac - Pointer to Global MAC structure
1609 *
1610 * @return eANI_BOOLEAN_TRUE When STA is waiting for Reassoc response from AP \n
1611 * else eANI_BOOLEAN_FALSE
1612 */
1613
1614eAniBoolean
1615limIsReassocInProgress(tpAniSirGlobal pMac,tpPESession psessionEntry)
1616{
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001617 if (psessionEntry == NULL)
1618 {
1619 return eANI_BOOLEAN_FALSE;
1620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 if(((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1622 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1623 (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1624 return eANI_BOOLEAN_TRUE;
1625
1626 return eANI_BOOLEAN_FALSE;
1627} /*** end limIsReassocInProgress() ***/
1628
Jeff Johnsone7245742012-09-05 17:12:55 -07001629#ifdef WLAN_FEATURE_11AC
1630tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
1631 tpSirSupportedRates pRates,
1632 tDot11fIEVHTCaps *pPeerVHTCaps,
1633 tpPESession psessionEntry)
1634{
1635 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001636 tANI_U32 selfStaDot11Mode=0;
1637 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001638
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001639// if(IS_DOT11_MODE_VHT(psessionEntry->dot11mode))
1640 if (IS_DOT11_MODE_VHT(selfStaDot11Mode))
Jeff Johnsone7245742012-09-05 17:12:55 -07001641 {
1642 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_MCS_MAP,&val) !=
1643 eSIR_SUCCESS )
1644 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001645 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001646 goto error;
1647 }
1648 pRates->vhtRxMCSMap = (tANI_U16)val;
1649
1650 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_MCS_MAP,&val ) !=
1651 eSIR_SUCCESS )
1652 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001653 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT TX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001654 goto error;
1655 }
1656 pRates->vhtTxMCSMap = (tANI_U16)val;
1657
1658 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1659 eSIR_SUCCESS )
1660 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001661 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001662 goto error;
1663 }
1664 pRates->vhtRxHighestDataRate = (tANI_U16)val;
1665
1666 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1667 eSIR_SUCCESS )
1668 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001669 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001670 goto error;
1671 }
1672 pRates->vhtTxHighestDataRate = (tANI_U16)val;
1673
1674 if( pPeerVHTCaps != NULL)
1675 {
1676 pRates->vhtTxHighestDataRate = SIR_MIN(pRates->vhtTxHighestDataRate, pPeerVHTCaps->txSupDataRate);
1677 pRates->vhtRxHighestDataRate = SIR_MIN(pRates->vhtRxHighestDataRate, pPeerVHTCaps->rxHighSupDataRate);
1678
Jeff Johnson1250df42012-12-10 14:31:52 -08001679 // Acquire PEER MCS map if we exceed.
Jeff Johnsone7245742012-09-05 17:12:55 -07001680 // We compare/update only the last 2 bits of the map as we support only single BSS.
1681 // Firmware takes care of this comparison
1682 pRates->vhtRxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1683 pRates->vhtRxMCSMap |= (pPeerVHTCaps->rxMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1684
1685 // Firmware takes care of this comparison
1686 pRates->vhtTxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1687 pRates->vhtTxMCSMap |= (pPeerVHTCaps->txMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1688 }
1689 }
1690 return eSIR_SUCCESS;
1691error:
1692
1693 return eSIR_FAILURE;
1694
1695}
1696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001697
1698/**
1699 * limPopulateOwnRateSet
1700 *
1701 * FUNCTION:
1702 * This function is called by limProcessAssocRsp() or
1703 * limAddStaInIBSS()
1704 * - It creates a combined rate set of 12 rates max which
1705 * comprises the basic and extended rates read from CFG
1706 * - It sorts the combined rate Set and copy it in the
1707 * rate array of the pSTA descriptor
1708 * - It sets the erpEnabled bit of the STA descriptor
1709 *
1710 * NOTE:
1711 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1712 * an A rate in the supported or extended rate sets
1713 *
1714 * @param pMac - Pointer to Global MAC structure
1715 * @param basicOnly - When passed value is true, only basic
1716 * rates are copied to DPH node else
1717 * all supported rates are copied
1718 * @return eSIR_SUCCESS or eSIR_FAILURE
1719 *
1720 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001721#ifdef WLAN_FEATURE_11AC
1722tSirRetStatus
1723limPopulateOwnRateSet(tpAniSirGlobal pMac,
1724 tpSirSupportedRates pRates,
1725 tANI_U8* pSupportedMCSSet,
1726 tANI_U8 basicOnly,
1727 tpPESession psessionEntry,
1728 tDot11fIEVHTCaps *pVHTCaps)
1729#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001730tSirRetStatus
1731limPopulateOwnRateSet(tpAniSirGlobal pMac,
1732 tpSirSupportedRates pRates,
1733 tANI_U8* pSupportedMCSSet,
1734 tANI_U8 basicOnly,
1735 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001736#endif
1737
Jeff Johnson295189b2012-06-20 16:38:30 -07001738{
1739 tSirMacRateSet tempRateSet;
1740 tSirMacRateSet tempRateSet2;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301741 tANI_U32 i,j,val,min,isArate;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 tANI_U32 phyMode = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001743 tANI_U32 selfStaDot11Mode=0;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301744
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 isArate = 0;
1746
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001747 wlan_cfgGetInt(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001748 limGetPhyMode(pMac, &phyMode, psessionEntry);
1749
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301750 /* Include 11b rates only when the device configured in
1751 auto, 11a/b/g or 11b_only */
1752 if ( (selfStaDot11Mode == WNI_CFG_DOT11_MODE_ALL) ||
1753 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11A) ||
1754 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11AC) ||
Leela Venkata Kiran Kumar Reddy Chiralac9a10e52013-08-29 16:37:15 -07001755 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11N) ||
1756 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11G) ||
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301757 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11B) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301759 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1760 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11B,
1761 (tANI_U8 *)&tempRateSet.rate, &val );
1762 tempRateSet.numRates = (tANI_U8) val;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001763 }
1764 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301765 tempRateSet.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001766
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301767 /* Include 11a rates when the device configured in non-11b mode */
1768 if (!IS_DOT11_MODE_11B(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301770 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1771 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11A,
1772 (tANI_U8 *)&tempRateSet2.rate, &val );
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 tempRateSet2.numRates = (tANI_U8) val;
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 }
1775 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301776 tempRateSet2.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001777
1778 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1779 {
1780 //we are in big trouble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001781 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 //panic
1783 goto error;
1784 }
1785
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 //copy all rates in tempRateSet, there are 12 rates max
1787 for (i = 0;i < tempRateSet2.numRates; i++)
1788 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1789 tempRateSet.numRates += tempRateSet2.numRates;
1790
1791 /**
1792 * Sort rates in tempRateSet (they are likely to be already sorted)
1793 * put the result in pSupportedRates
1794 */
1795 {
1796 tANI_U8 aRateIndex = 0;
1797 tANI_U8 bRateIndex = 0;
1798
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301799 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 for(i = 0;i < tempRateSet.numRates; i++)
1801 {
1802 min = 0;
1803 val = 0xff;
1804 isArate = 0;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001805 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 {
1807 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1808 {
1809 val = tempRateSet.rate[j] & 0x7f;
1810 min = j;
1811 }
1812 }
1813
1814 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1815 isArate = 1;
1816
1817 /*
1818 * HAL needs to know whether the rate is basic rate or not, as it needs to
1819 * update the response rate table accordingly. e.g. if one of the 11a rates is
1820 * basic rate, then that rate can be used for sending control frames.
1821 * HAL updates the response rate table whenever basic rate set is changed.
1822 */
1823 if (basicOnly)
1824 {
1825 if (tempRateSet.rate[min] & 0x80)
1826 {
1827 if (isArate)
1828 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1829 else
1830 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1831 }
1832 }
1833 else
1834 {
1835 if (isArate)
1836 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1837 else
1838 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1839 }
1840 tempRateSet.rate[min] = 0xff;
1841 }
1842
1843 }
1844
1845
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001846 //if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1847 if (IS_DOT11_MODE_HT(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 {
1849 val = SIZE_OF_SUPPORTED_MCS_SET;
1850 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1851 pRates->supportedMCSSet,
1852 &val) != eSIR_SUCCESS)
1853 {
1854 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001855 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 goto error;
1857 }
1858
1859
1860 //if supported MCS Set of the peer is passed in, then do the intersection
1861 //else use the MCS set from local CFG.
1862
1863 if(pSupportedMCSSet != NULL)
1864 {
1865 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1866 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1867
1868 }
1869
Abhishek Singh525045c2014-12-15 17:18:45 +05301870 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05301872 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 }
1874
Jeff Johnsone7245742012-09-05 17:12:55 -07001875#ifdef WLAN_FEATURE_11AC
1876 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1877#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001878
1879 return eSIR_SUCCESS;
1880
1881 error:
1882
1883 return eSIR_FAILURE;
1884} /*** limPopulateOwnRateSet() ***/
1885
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001886#ifdef WLAN_FEATURE_11AC
1887tSirRetStatus
1888limPopulatePeerRateSet(tpAniSirGlobal pMac,
1889
1890 tpSirSupportedRates pRates,
1891 tANI_U8* pSupportedMCSSet,
1892 tANI_U8 basicOnly,
1893 tpPESession psessionEntry,
1894 tDot11fIEVHTCaps *pVHTCaps)
1895#else
1896tSirRetStatus
1897limPopulatePeerRateSet(tpAniSirGlobal pMac,
1898 tpSirSupportedRates pRates,
1899 tANI_U8* pSupportedMCSSet,
1900 tANI_U8 basicOnly,
1901 tpPESession psessionEntry)
1902#endif
1903{
1904 tSirMacRateSet tempRateSet;
1905 tSirMacRateSet tempRateSet2;
1906 tANI_U32 i,j,val,min,isArate;
1907 isArate = 0;
1908
1909 /* copy operational rate set from psessionEntry */
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001910 if ( psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX )
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001911 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301912 vos_mem_copy((tANI_U8 *)tempRateSet.rate,
1913 (tANI_U8*)(psessionEntry->rateSet.rate),
1914 psessionEntry->rateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001915 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1916 }
1917 else
1918 {
1919 limLog(pMac, LOGE, FL("more than SIR_MAC_RATESET_EID_MAX rates\n"));
1920 goto error;
1921 }
Leela Venkata Kiran Kumar Reddy Chirala891bf062013-10-03 14:30:53 -07001922 if ((psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1923 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1924 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11N))
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001925 {
1926
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001927 if (psessionEntry->extRateSet.numRates <= SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001928 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301929 vos_mem_copy((tANI_U8 *)tempRateSet2.rate,
1930 (tANI_U8*)(psessionEntry->extRateSet.rate),
1931 psessionEntry->extRateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001932 tempRateSet2.numRates = psessionEntry->extRateSet.numRates;
1933 }
1934 else {
1935 limLog(pMac, LOGE, FL("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates\n"));
1936 goto error;
1937 }
1938 }
1939 else
1940 tempRateSet2.numRates = 0;
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001941 if ((tempRateSet.numRates + tempRateSet2.numRates) > SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001942 {
1943 //we are in big trouble
1944 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
1945 goto error;
1946 }
1947
1948
1949 //copy all rates in tempRateSet, there are 12 rates max
1950 for (i = 0;i < tempRateSet2.numRates; i++)
1951 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1952 tempRateSet.numRates += tempRateSet2.numRates;
1953 /**
1954 * Sort rates in tempRateSet (they are likely to be already sorted)
1955 * put the result in pSupportedRates
1956 */
1957 {
1958 tANI_U8 aRateIndex = 0;
1959 tANI_U8 bRateIndex = 0;
Kiet Lam842c3e12013-11-16 22:40:57 +05301960 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001961 for(i = 0;i < tempRateSet.numRates; i++)
1962 {
1963 min = 0;
1964 val = 0xff;
1965 isArate = 0;
1966 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
1967 {
1968 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1969 {
1970 val = tempRateSet.rate[j] & 0x7f;
1971 min = j;
1972 }
1973 }
1974 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1975 isArate = 1;
1976 /*
1977 * HAL needs to know whether the rate is basic rate or not, as it needs to
1978 * update the response rate table accordingly. e.g. if one of the 11a rates is
1979 * basic rate, then that rate can be used for sending control frames.
1980 * HAL updates the response rate table whenever basic rate set is changed.
1981 */
1982 if (basicOnly)
1983 {
1984 if (tempRateSet.rate[min] & 0x80)
1985 {
1986 if (isArate)
1987 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1988 else
1989 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1990 }
1991 }
1992 else
1993 {
1994 if (isArate)
1995 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1996 else
1997 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1998 }
1999 tempRateSet.rate[min] = 0xff;
2000 }
2001 }
2002
2003
2004 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode))
2005 {
2006 val = SIZE_OF_SUPPORTED_MCS_SET;
2007 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2008 pRates->supportedMCSSet,
2009 &val) != eSIR_SUCCESS)
2010 {
2011 /// Could not get rateset from CFG. Log error.
2012 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
2013 goto error;
2014 }
2015 //if supported MCS Set of the peer is passed in, then do the intersection
2016 //else use the MCS set from local CFG.
2017 if(pSupportedMCSSet != NULL)
2018 {
2019 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2020 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
2021 }
Abhishek Singh525045c2014-12-15 17:18:45 +05302022 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002023 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05302024 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002025 }
2026#ifdef WLAN_FEATURE_11AC
2027 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
2028#endif
2029 return eSIR_SUCCESS;
2030 error:
2031 return eSIR_FAILURE;
2032} /*** limPopulatePeerRateSet() ***/
2033
Jeff Johnson295189b2012-06-20 16:38:30 -07002034/**
2035 * limPopulateMatchingRateSet
2036 * FUNCTION:
2037 * This is called at the time of Association Request
2038 * processing on AP and while adding peer's context
2039 * in IBSS role to process the CFG rate sets and
2040 * the rate sets received in the Assoc request on AP
2041 * or Beacon/Probe Response from peer in IBSS.
2042 *
2043 * LOGIC:
2044 * 1. It makes the intersection between our own rate Sat
2045 * and extemcded rate set and the ones received in the
2046 * association request.
2047 * 2. It creates a combined rate set of 12 rates max which
2048 * comprised the basic and extended rates
2049 * 3. It sorts the combined rate Set and copy it in the
2050 * rate array of the pSTA descriptor
2051 *
2052 * ASSUMPTION:
2053 * The parser has already ensured unicity of the rates in the
2054 * association request structure
2055 *
2056 * @param: pMac - Pointer to Global MAC structure
2057 * pStaDs - Pointer to DPH node
2058 * pOperRateSet - Pointer to peer's supported rateset
2059 * pExtRateSet - Pointer to peer's extended rateset
2060 *
2061 * @return: eSIR_SUCCESS or eSIR_FAILURE
2062 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002063#ifdef WLAN_FEATURE_11AC
2064tSirRetStatus
2065limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2066 tpDphHashNode pStaDs,
2067 tSirMacRateSet *pOperRateSet,
2068 tSirMacRateSet *pExtRateSet,
2069 tANI_U8* pSupportedMCSSet,
2070 tSirMacPropRateSet *pAniLegRateSet,
2071 tpPESession psessionEntry,
2072 tDot11fIEVHTCaps *pVHTCaps)
Jeff Johnson295189b2012-06-20 16:38:30 -07002073
Jeff Johnsone7245742012-09-05 17:12:55 -07002074#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002075tSirRetStatus
2076limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2077 tpDphHashNode pStaDs,
2078 tSirMacRateSet *pOperRateSet,
2079 tSirMacRateSet *pExtRateSet,
2080 tANI_U8* pSupportedMCSSet,
2081 tSirMacPropRateSet *pAniLegRateSet,
2082 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07002083#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002084{
2085 tSirMacRateSet tempRateSet;
2086 tSirMacRateSet tempRateSet2;
2087 tANI_U32 i,j,val,min,isArate;
2088 tANI_U32 phyMode;
2089 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2090
2091 isArate=0;
2092
2093 // limGetPhyMode(pMac, &phyMode);
2094 limGetPhyMode(pMac, &phyMode, psessionEntry);
2095
2096 // get own rate set
2097 // val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2098 #if 0
2099 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2100 (tANI_U8 *) &tempRateSet.rate,
2101 &val) != eSIR_SUCCESS)
2102 {
2103 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002104 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 }
2106
2107 #endif // TO SUPPORT BT-AMP
2108
2109 /* copy operational rate set from psessionEntry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302110 vos_mem_copy((tempRateSet.rate), (psessionEntry->rateSet.rate),
2111 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 tempRateSet.numRates = (tANI_U8) psessionEntry->rateSet.numRates;
2113
2114 if (phyMode == WNI_CFG_PHY_MODE_11G)
2115 {
2116
2117 #if 0
2118 // get own extended rate set
2119 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2120 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
2121 (tANI_U8 *) &tempRateSet2.rate,
2122 &val) != eSIR_SUCCESS)
2123 #endif
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302124 vos_mem_copy((tempRateSet2.rate), (psessionEntry->extRateSet.rate),
2125 psessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 tempRateSet2.numRates = (tANI_U8) psessionEntry->extRateSet.numRates;
2127 }
2128 else
2129 tempRateSet2.numRates = 0;
2130
2131 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2132 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002133 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 goto error;
2135 }
2136
2137 /**
2138 * Handling of the rate set IEs is the following:
2139 * - keep only rates that we support and that the station supports
2140 * - sort and the rates into the pSta->rate array
2141 */
2142
2143 // Copy all rates in tempRateSet, there are 12 rates max
2144 for(i = 0; i < tempRateSet2.numRates; i++)
2145 tempRateSet.rate[i + tempRateSet.numRates] =
2146 tempRateSet2.rate[i];
2147
2148 tempRateSet.numRates += tempRateSet2.numRates;
2149
2150 /**
2151 * Sort rates in tempRateSet (they are likely to be already sorted)
2152 * put the result in tempRateSet2
2153 */
2154 tempRateSet2.numRates = 0;
2155
2156 for(i = 0;i < tempRateSet.numRates; i++)
2157 {
2158 min = 0;
2159 val = 0xff;
2160
2161 for(j = 0;j < tempRateSet.numRates; j++)
2162 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2163 {
2164 val = tempRateSet.rate[j] & 0x7f;
2165 min = j;
2166 }
2167
2168 tempRateSet2.rate[tempRateSet2.numRates++] =
2169 tempRateSet.rate[min];
2170 tempRateSet.rate[min] = 0xff;
2171 }
2172
2173
2174 /**
2175 * Copy received rates in tempRateSet, the parser has ensured
2176 * unicity of the rates so there cannot be more than 12
2177 */
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002178 for(i = 0; (i < pOperRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 {
2180 tempRateSet.rate[i] = pOperRateSet->rate[i];
2181 }
2182
2183 tempRateSet.numRates = pOperRateSet->numRates;
2184
2185 if (pExtRateSet->numRates)
2186 {
2187 if((tempRateSet.numRates + pExtRateSet->numRates) > 12 )
2188 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302189 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 "Sum of SUPPORTED and EXTENDED Rate Set (%1d) exceeds 12!",
2191 tempRateSet.numRates + pExtRateSet->numRates );
2192
2193 if( tempRateSet.numRates < 12 )
2194 {
2195 int found = 0;
2196 int tail = tempRateSet.numRates;
2197
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002198 for( i = 0; (i < pExtRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX); i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 {
2200 found = 0;
2201 for( j = 0; j < (tANI_U32) tail; j++ )
2202 {
2203 if((tempRateSet.rate[j] & 0x7F) ==
2204 (pExtRateSet->rate[i] & 0x7F))
2205 {
2206 found = 1;
2207 break;
2208 }
2209 }
2210
2211 if( !found )
2212 {
2213 tempRateSet.rate[tempRateSet.numRates++] =
2214 pExtRateSet->rate[i];
2215
2216 if( tempRateSet.numRates >= 12 )
2217 break;
2218 }
2219 }
2220 }
2221 else
Abhishek Singh525045c2014-12-15 17:18:45 +05302222 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 "Relying only on the SUPPORTED Rate Set IE..." );
2224 }
2225 else
2226 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002227 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 -07002228 tempRateSet.rate[i+j] = pExtRateSet->rate[j];
2229
2230 tempRateSet.numRates += pExtRateSet->numRates;
2231 }
2232 }
2233
2234 {
2235 tpSirSupportedRates rates = &pStaDs->supportedRates;
2236 tANI_U8 aRateIndex = 0;
2237 tANI_U8 bRateIndex = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302238 vos_mem_set((tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002239 for(i = 0;(i < tempRateSet2.numRates && i < SIR_MAC_RATESET_EID_MAX ); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002241 for(j = 0;(j < tempRateSet.numRates && j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 {
2243 if ((tempRateSet2.rate[i] & 0x7F) ==
2244 (tempRateSet.rate[j] & 0x7F))
2245 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2247 {
2248 isArate=1;
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002249 if (aRateIndex < SIR_NUM_11A_RATES)
2250 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 }
2252 else
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002253 {
2254 if (bRateIndex < SIR_NUM_11B_RATES)
2255 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 break;
2258 }
2259 }
2260 }
2261
2262
2263 //Now add the Polaris rates only when Proprietary rates are enabled.
2264 val = 0;
2265 if(wlan_cfgGetInt(pMac, WNI_CFG_PROPRIETARY_RATES_ENABLED, &val) != eSIR_SUCCESS)
2266 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002267 limLog(pMac, LOGP, FL("could not retrieve prop rate enabled flag from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 }
2269 else if(val)
2270 {
2271 for(i=0; i<pAniLegRateSet->numPropRates; i++)
2272 rates->aniLegacyRates[i] = pAniLegRateSet->propRate[i];
2273 }
2274
2275 }
2276
2277
2278 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002279#ifdef FEATURE_WLAN_TDLS
2280 if(pStaDs->mlmStaContext.htCapability)
2281#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2283 (pStaDs->mlmStaContext.htCapability))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002284#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 {
2286 val = SIZE_OF_SUPPORTED_MCS_SET;
2287 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2288 mcsSet,
2289 &val) != eSIR_SUCCESS)
2290 {
2291 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002292 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 goto error;
2294 }
2295
2296 for(i=0; i<val; i++)
2297 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2298
Abhishek Singh525045c2014-12-15 17:18:45 +05302299 limLog(pMac, LOG1, FL(" MCS Rate Set Bitmap from CFG and DPH : "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2301 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302302 limLog(pMac, LOG1,FL("%x %x "), mcsSet[i],
2303 pStaDs->supportedRates.supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 }
2305 }
2306
Jeff Johnsone7245742012-09-05 17:12:55 -07002307#ifdef WLAN_FEATURE_11AC
2308 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 /**
2311 * Set the erpEnabled bit iff the phy is in G mode and at least
2312 * one A rate is supported
2313 */
2314 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2315 pStaDs->erpEnabled = eHAL_SET;
2316
2317
2318
2319 return eSIR_SUCCESS;
2320
2321 error:
2322
2323 return eSIR_FAILURE;
2324} /*** limPopulateMatchingRateSet() ***/
2325
2326
2327
2328/**
2329 * limAddSta()
2330 *
2331 *FUNCTION:
2332 * This function is called to add an STA context at hardware
2333 * whenever a STA is (Re) Associated.
2334 *
2335 *LOGIC:
2336 *
2337 *ASSUMPTIONS:
2338 * NA
2339 *
2340 *NOTE:
2341 * NA
2342 *
2343 * @param pMac - Pointer to Global MAC structure
2344 * @param pStaDs - Pointer to the STA datastructure created by
2345 * LIM and maintained by DPH
2346 * @return retCode - Indicates success or failure return code
2347 */
2348
2349tSirRetStatus
2350limAddSta(
2351 tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002352 tpDphHashNode pStaDs, tANI_U8 updateEntry, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002353{
2354 tpAddStaParams pAddStaParams = NULL;
2355 tSirMsgQ msgQ;
2356 tSirRetStatus retCode = eSIR_SUCCESS;
2357 tSirMacAddr staMac, *pStaAddr;
2358 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 tpSirAssocReq pAssocReq;
2360 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 #if 0
2362 retCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2363 if (retCode != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002364 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 #endif //To SUPPORT BT-AMP
2366
2367
2368 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2369
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302370 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
2371 psessionEntry->smeSessionId, updateEntry, psessionEntry->limSystemRole);
2372
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302373 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2374 if (NULL == pAddStaParams)
2375 {
2376 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
2377 return eSIR_MEM_ALLOC_FAILED;
2378 }
2379 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002380
2381 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||
2382 (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE) ||
2383 (limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) )
2384 pStaAddr = &pStaDs->staAddr;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002385#ifdef FEATURE_WLAN_TDLS
2386 /* SystemRole shouldn't be matter if staType is TDLS peer */
2387 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2388 {
2389 pStaAddr = &pStaDs->staAddr ;
2390 }
2391#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 else
2393 pStaAddr = &staMac;
2394
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302395 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": Subtype(Assoc/Reassoc): %d "),
2396 MAC_ADDR_ARRAY(*pStaAddr), pStaDs->mlmStaContext.subType);
2397
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302398 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2399 (tANI_U8 *) *pStaAddr, sizeof(tSirMacAddr));
2400 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2401 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002402
2403 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
2404
2405 //Copy legacy rates
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302406 vos_mem_copy ((tANI_U8*)&pAddStaParams->supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 (tANI_U8*)&pStaDs->supportedRates, sizeof(tSirSupportedRates));
2408
2409 pAddStaParams->assocId = pStaDs->assocId;
2410
2411 pAddStaParams->wmmEnabled = pStaDs->qosMode;
2412 pAddStaParams->listenInterval = pStaDs->mlmStaContext.listenInterval;
2413 pAddStaParams->shortPreambleSupported = pStaDs->shortPreambleEnabled;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302414 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 if((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) && (pStaDs->mlmStaContext.subType == LIM_REASSOC))
2416 {
2417 /* TBD - need to remove this REASSOC check after fixinf rmmod issue */
2418 pAddStaParams->updateSta = pStaDs->mlmStaContext.updateContext;
2419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 pStaDs->valid = 0;
2421 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2422
Abhishek Singh525045c2014-12-15 17:18:45 +05302423 limLog(pMac, LOG1, FL(" Assoc ID: %d wmmEnabled = %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302424 " shortPreambleSupported: %d "), pAddStaParams->assocId,
2425 pAddStaParams->wmmEnabled, pAddStaParams->listenInterval,
2426 pAddStaParams->shortPreambleSupported);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002427 // This will indicate HAL to "allocate" a new STA index
2428#ifdef FEATURE_WLAN_TDLS
2429 /* As there is corner case in-between add_sta and change_sta,if del_sta for other staIdx happened,
2430 * firmware return wrong staIdx (recently removed staIdx). Until we get a confirmation from the
2431 * firmware team it is now return correct staIdx for same sta_mac_addr for update case, we want
2432 * to get around it by passing valid staIdx given by add_sta time.
2433 */
2434 if((STA_ENTRY_TDLS_PEER == pStaDs->staType) &&
2435 (true == updateEntry))
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302436 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002437 pAddStaParams->staIdx = pStaDs->staIndex;
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302438 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002439 else
2440#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302441#ifdef SAP_AUTH_OFFLOAD
2442 if (!pMac->sap_auth_offload)
2443 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2444 else
2445 pAddStaParams->staIdx = pStaDs->staIndex;
2446#else
2447 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2448#endif
2449
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 pAddStaParams->staType = pStaDs->staType;
2451
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002452 pAddStaParams->updateSta = updateEntry;
2453
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2455 pAddStaParams->respReqd = 1;
2456 //Update HT Capability
2457
2458 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 -07002459 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Jeff Johnsone7245742012-09-05 17:12:55 -07002461#ifdef WLAN_FEATURE_11AC
2462 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2463#endif
2464 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002465#ifdef FEATURE_WLAN_TDLS
2466 /* SystemRole shouldn't be matter if staType is TDLS peer */
2467 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
Hoonki Lee99e53782013-02-12 18:07:03 -08002468 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002469 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Hoonki Lee99e53782013-02-12 18:07:03 -08002470#ifdef WLAN_FEATURE_11AC
2471 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2472#endif
2473 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002474#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 else
Jeff Johnsone7245742012-09-05 17:12:55 -07002476 {
2477 pAddStaParams->htCapable = psessionEntry->htCapability;
2478#ifdef WLAN_FEATURE_11AC
2479 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
2480#endif
2481
2482 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302483#ifdef WLAN_FEATURE_11AC
Abhishek Singh525045c2014-12-15 17:18:45 +05302484 limLog(pMac, LOG1, FL("vhtCapable: %d "), pAddStaParams->vhtCapable);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302485#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302486 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302487 pAddStaParams->staIdx,pAddStaParams->updateSta,
2488 pAddStaParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002489
2490 pAddStaParams->greenFieldCapable = pStaDs->htGreenfield;
2491 pAddStaParams->maxAmpduDensity= pStaDs->htAMpduDensity;
2492 pAddStaParams->maxAmpduSize = pStaDs->htMaxRxAMpduFactor;
2493 pAddStaParams->fDsssCckMode40Mhz = pStaDs->htDsssCckRate40MHzSupport;
2494 pAddStaParams->fShortGI20Mhz = pStaDs->htShortGI20Mhz;
2495 pAddStaParams->fShortGI40Mhz = pStaDs->htShortGI40Mhz;
2496 pAddStaParams->lsigTxopProtection = pStaDs->htLsigTXOPProtection;
2497 pAddStaParams->maxAmsduSize = pStaDs->htMaxAmsduLength;
2498 pAddStaParams->txChannelWidthSet = pStaDs->htSupportedChannelWidthSet;
2499 pAddStaParams->mimoPS = pStaDs->htMIMOPSState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002500
Abhishek Singh525045c2014-12-15 17:18:45 +05302501 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302502 "maxAmpduDensity = %d"), pAddStaParams->greenFieldCapable,
2503 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
2504
Abhishek Singh525045c2014-12-15 17:18:45 +05302505 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302506 "fShortGI40Mhz: %d"), pAddStaParams->fDsssCckMode40Mhz,
2507 pAddStaParams->fShortGI20Mhz, pAddStaParams->fShortGI40Mhz);
2508
Abhishek Singh525045c2014-12-15 17:18:45 +05302509 limLog(pMac, LOG1, FL("lsigTxopProtection: %d maxAmsduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302510 "txChannelWidthSet: %d mimoPS: %d "), pAddStaParams->lsigTxopProtection,
2511 pAddStaParams->maxAmsduSize,pAddStaParams->txChannelWidthSet,
2512 pAddStaParams->mimoPS);
2513
Jeff Johnsone7245742012-09-05 17:12:55 -07002514#ifdef WLAN_FEATURE_11AC
2515 if(pAddStaParams->vhtCapable)
2516 {
Mohit Khanna7d5aeb22012-09-11 16:21:57 -07002517 pAddStaParams->vhtTxChannelWidthSet = pStaDs->vhtSupportedChannelWidthSet;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002518 pAddStaParams->vhtTxBFCapable =
Hoonki Lee99e53782013-02-12 18:07:03 -08002519#ifdef FEATURE_WLAN_TDLS
2520 (( STA_ENTRY_PEER == pStaDs->staType ) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) ?
2521 pStaDs->vhtBeamFormerCapable : psessionEntry->txBFIniFeatureEnabled ;
2522#else
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002523 ( STA_ENTRY_PEER == pStaDs->staType ) ? pStaDs->vhtBeamFormerCapable :
2524 psessionEntry->txBFIniFeatureEnabled ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002525#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302526 limLog(pMac, LOG1, FL("vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302527 pAddStaParams->vhtTxChannelWidthSet,pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07002528 }
2529#endif
2530
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002531#ifdef FEATURE_WLAN_TDLS
2532 if((STA_ENTRY_PEER == pStaDs->staType) ||
2533 (STA_ENTRY_TDLS_PEER == pStaDs->staType))
2534#else
2535 if (STA_ENTRY_PEER == pStaDs->staType)
2536#endif
2537 {
2538 /* peer STA get the LDPC capability from pStaDs, which populated from
2539 * HT/VHT capability*/
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05302540 if(pAddStaParams->vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP)
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002541 {
2542 pAddStaParams->htLdpcCapable = 0;
2543 pAddStaParams->vhtLdpcCapable = 0;
2544 }
2545 else
2546 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05302547 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
2548 pAddStaParams->htLdpcCapable = pStaDs->htLdpcCapable;
2549 else
2550 pAddStaParams->htLdpcCapable = 0;
2551 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
2552 pAddStaParams->vhtLdpcCapable = pStaDs->vhtLdpcCapable;
2553 else
2554 pAddStaParams->vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002555 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002556 }
2557 else if( STA_ENTRY_SELF == pStaDs->staType)
2558 {
2559 /* For Self STA get the LDPC capability from config.ini*/
2560 pAddStaParams->htLdpcCapable =
2561 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2562 pAddStaParams->vhtLdpcCapable =
2563 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2564 }
2565
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 /* Update PE session ID*/
2567 pAddStaParams->sessionId = psessionEntry->peSessionId;
2568
2569 if (psessionEntry->parsedAssocReq != NULL)
2570 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 // Get a copy of the already parsed Assoc Request
2572 pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pStaDs->assocId];
2573 if ( pAssocReq && pAssocReq->addIEPresent && pAssocReq->addIE.length ) {
2574 p2pIe = limGetP2pIEPtr(pMac, pAssocReq->addIE.addIEdata, pAssocReq->addIE.length);
2575 }
2576 pAddStaParams->p2pCapableSta = (p2pIe != NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 }
2578
2579 //Disable BA. It will be set as part of ADDBA negotiation.
2580 for( i = 0; i < STACFG_MAX_TC; i++ )
2581 {
2582 pAddStaParams->staTCParams[i].txUseBA = eBA_DISABLE;
2583 pAddStaParams->staTCParams[i].rxUseBA = eBA_DISABLE;
2584 }
2585
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002586#ifdef FEATURE_WLAN_TDLS
2587 if(pStaDs->wmeEnabled && \
2588 ((eLIM_AP_ROLE == psessionEntry->limSystemRole) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) )
2589#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 if(pStaDs->wmeEnabled && (eLIM_AP_ROLE == psessionEntry->limSystemRole))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002591#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 {
2593 pAddStaParams->uAPSD = 0;
2594 /* update UAPSD and send it to LIM to add STA */
2595 // bitmap MSB <- LSB MSB 4 bits are for
2596 // trigger enabled AC setting and LSB 4 bits
2597 // are for delivery enabled AC setting
2598 // 7 6 5 4 3 2 1 0
2599 // BE BK VI VO BE BK VI VO
2600 pAddStaParams->uAPSD |= pStaDs->qos.capability.qosInfo.acvo_uapsd;
2601 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acvi_uapsd << 1);
2602 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbk_uapsd << 2);
2603 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbe_uapsd << 3);
2604 //making delivery enabled and trigger enabled setting the same.
2605 pAddStaParams->uAPSD |= pAddStaParams->uAPSD << 4;
2606
2607 pAddStaParams->maxSPLen = pStaDs->qos.capability.qosInfo.maxSpLen;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302608 limLog( pMac, LOG1, FL("uAPSD = 0x%x, maxSpLen = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 pAddStaParams->uAPSD, pAddStaParams->maxSPLen);
2610 }
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002611
2612#ifdef WLAN_FEATURE_11W
2613 pAddStaParams->rmfEnabled = pStaDs->rmfEnabled;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302614 limLog( pMac, LOG1, FL( "PMF enabled %d"), pAddStaParams->rmfEnabled);
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002615#endif
2616
Abhishek Singh525045c2014-12-15 17:18:45 +05302617 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302618 "p2pCapableSta: %d"), pAddStaParams->htLdpcCapable,
2619 pAddStaParams->vhtLdpcCapable, pAddStaParams->p2pCapableSta);
2620
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302621#ifdef SAP_AUTH_OFFLOAD
2622 if (pMac->sap_auth_offload) {
2623 pAddStaParams->dpuIndex = pStaDs->dpuIndex;
2624 pAddStaParams->bcastDpuIndex = pStaDs->bcastDpuIndex;
2625 pAddStaParams->bcastMgmtDpuIdx = pStaDs->bcastMgmtDpuIdx;
2626 pAddStaParams->ucUcastSig = pStaDs->ucUcastSig;
2627 pAddStaParams->ucBcastSig = pStaDs->ucBcastSig;
2628 pAddStaParams->ucMgmtSig = pStaDs->ucMgmtSig;
Agrawal Ashishce67f362017-01-05 20:10:58 +05302629 pAddStaParams->bssIdx = pStaDs->bssId;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302630 }
2631#endif
2632
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002633 //we need to defer the message until we get the response back from HAL.
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 if (pAddStaParams->respReqd)
2635 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002636
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302637#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302638 if (pMac->sap_auth_offload && LIM_IS_AP_ROLE(psessionEntry))
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302639 msgQ.type = WDA_SAP_OFL_ADD_STA;
2640 else
2641 msgQ.type = WDA_ADD_STA_REQ;
2642#else
2643 msgQ.type = WDA_ADD_STA_REQ;
2644#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002645
2646 msgQ.reserved = 0;
2647 msgQ.bodyptr = pAddStaParams;
2648 msgQ.bodyval = 0;
2649
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002650 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ for assocId %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 pStaDs->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002652 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002653
2654 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2655 if( eSIR_SUCCESS != retCode)
2656 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002657 if (pAddStaParams->respReqd)
2658 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002659 limLog( pMac, LOGE, FL("ADD_STA_REQ for aId %d failed (reason %X)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 pStaDs->assocId, retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302661 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 }
2663
2664 return retCode;
2665}
2666
2667
2668/**
2669 * limDelSta()
2670 *
2671 *FUNCTION:
2672 * This function is called to delete an STA context at hardware
2673 * whenever a STA is disassociated
2674 *
2675 *LOGIC:
2676 *
2677 *ASSUMPTIONS:
2678 * NA
2679 *
2680 *NOTE:
2681 * NA
2682 *
2683 * @param pMac - Pointer to Global MAC structure
2684 * @param pStaDs - Pointer to the STA datastructure created by
2685 * LIM and maintained by DPH
2686 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2687 * or not (false)
2688 * @return retCode - Indicates success or failure return code
2689 */
2690
2691tSirRetStatus
2692limDelSta(
2693 tpAniSirGlobal pMac,
2694 tpDphHashNode pStaDs,
2695 tANI_BOOLEAN fRespReqd,
2696 tpPESession psessionEntry)
2697{
2698 tpDeleteStaParams pDelStaParams = NULL;
2699 tSirMsgQ msgQ;
2700 tSirRetStatus retCode = eSIR_SUCCESS;
Sravan Kumar Kairam18705ef2017-09-21 18:37:50 +05302701 tANI_U8 channelNum = 0;
2702 tANI_U32 cfgValue = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002703
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302704 pDelStaParams = vos_mem_malloc(sizeof( tDeleteStaParams ));
2705 if (NULL == pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302707 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 return eSIR_MEM_ALLOC_FAILED;
2709 }
2710
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302711 vos_mem_set((tANI_U8 *) pDelStaParams, sizeof(tDeleteStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002712
Sravan Kumar Kairam18705ef2017-09-21 18:37:50 +05302713 wlan_cfgGetInt(pMac, WNI_CFG_ACTIVE_PASSIVE_CON, &cfgValue);
2714
2715 channelNum = limGetCurrentOperatingChannel(pMac);
2716 limLog(pMac, LOG1, FL("Current Operating channel is %d"), channelNum);
2717 if (!cfgValue && (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) &&
2718 limIsconnectedOnDFSChannel(channelNum))
2719 {
2720 limCovertChannelScanType(pMac, channelNum, false);
2721 pMac->lim.dfschannelList.timeStamp[channelNum] = 0;
2722 }
2723
2724
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 //
2726 // DPH contains the STA index only for "peer" STA entries.
2727 // LIM global contains "self" STA index
2728 // Thus,
2729 // if( STA role )
2730 // get STA index from LIM global
2731 // else
2732 // get STA index from DPH
2733 //
2734
2735#if 0
2736 /* Since we have not created any STA, no need to send msg to delete
2737 * STA to HAL */
2738 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
2739 pDelStaParams->staIdx = 1; /* TODO : This is workaround. Need to find right STA Index before sending to HAL */
2740 //return retCode;
2741 }
2742#endif
2743
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002744#ifdef FEATURE_WLAN_TDLS
2745 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)) )
2746#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 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 -08002748#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 pDelStaParams->staIdx= psessionEntry->staId;
2750
2751 else
2752 pDelStaParams->staIdx= pStaDs->staIndex;
2753
2754 pDelStaParams->assocId = pStaDs->assocId;
2755 pStaDs->valid = 0;
2756
2757 if (! fRespReqd)
2758 pDelStaParams->respReqd = 0;
2759 else
2760 {
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302761 if (pStaDs->staType != STA_ENTRY_TDLS_PEER) {
2762 /**
2763 * when limDelSta is called from processSmeAssocCnf
2764 * then mlmState is already set properly.
2765 */
2766 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
2767 GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs)) {
2768 MTRACE(macTrace
2769 (pMac, TRACE_CODE_MLM_STATE,
2770 psessionEntry->peSessionId,
2771 eLIM_MLM_WT_DEL_STA_RSP_STATE));
2772 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs,
2773 eLIM_MLM_WT_DEL_STA_RSP_STATE);
2774 }
2775 if ((eLIM_STA_ROLE ==
2776 GET_LIM_SYSTEM_ROLE(psessionEntry)) ||
2777 (eLIM_BT_AMP_STA_ROLE ==
2778 GET_LIM_SYSTEM_ROLE(psessionEntry))) {
2779 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
2780 psessionEntry->peSessionId,
2781 eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002782
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302783 psessionEntry->limMlmState =
2784 eLIM_MLM_WT_DEL_STA_RSP_STATE;
2785 }
2786
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 }
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302788 /**
2789 * we need to defer the message until we get the
2790 * response back from HAL.
2791 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302793 pDelStaParams->respReqd = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 }
2795
2796 /* Update PE session ID*/
2797 pDelStaParams->sessionId = psessionEntry->peSessionId;
2798
2799 pDelStaParams->status = eHAL_STATUS_SUCCESS;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302800#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302801 if (pMac->sap_auth_offload && LIM_IS_AP_ROLE(psessionEntry))
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302802 msgQ.type = WDA_SAP_OFL_DEL_STA;
2803 else
2804 msgQ.type = WDA_DELETE_STA_REQ;
2805#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 msgQ.type = WDA_DELETE_STA_REQ;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302807#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 msgQ.reserved = 0;
2809 msgQ.bodyptr = pDelStaParams;
2810 msgQ.bodyval = 0;
2811
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302812 limLog( pMac, LOG1, FL( "Sessionid %d :Sending SIR_HAL_DELETE_STA_REQ "
2813 "for STAID: %X and AssocID: %d MAC : "MAC_ADDRESS_STR ),
2814 pDelStaParams->sessionId,
2815 pDelStaParams->staIdx, pDelStaParams->assocId,
2816 MAC_ADDR_ARRAY(pStaDs->staAddr));
2817
Jeff Johnsone7245742012-09-05 17:12:55 -07002818 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2820 if( eSIR_SUCCESS != retCode)
2821 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002822 if(fRespReqd)
2823 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002824 limLog( pMac, LOGE, FL("Posting DELETE_STA_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302826 vos_mem_free(pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 }
2828
2829 return retCode;
2830}
2831
2832#if defined WLAN_FEATURE_VOWIFI_11R
2833/*------------------------------------------------------------------------
2834 * limAddFTStaSelf()
2835 *
2836 * FUNCTION:
2837 *
2838 * This function is called to add a STA once we have connected with a new
2839 * AP, that we have performed an FT to.
2840 *
2841 * The Add STA Response is created and now after the ADD Bss Is Successful
2842 * we add the self sta. We update with the association id from the reassoc
2843 * response from the AP.
2844 *------------------------------------------------------------------------
2845 */
2846tSirRetStatus limAddFTStaSelf(tpAniSirGlobal pMac, tANI_U16 assocId, tpPESession psessionEntry)
2847{
2848 tpAddStaParams pAddStaParams = NULL;
2849 tSirMsgQ msgQ;
2850 tSirRetStatus retCode = eSIR_SUCCESS;
2851
2852 pAddStaParams = pMac->ft.ftPEContext.pAddStaReq;
2853 pAddStaParams->assocId = assocId;
2854
2855 msgQ.type = SIR_HAL_ADD_STA_REQ;
2856 msgQ.reserved = 0;
2857 msgQ.bodyptr = pAddStaParams;
2858 msgQ.bodyval = 0;
2859
2860
2861#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002862 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ), pAddStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002863#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002864 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002865
2866 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002867 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2869 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2870 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002871 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302872 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 }
2874 //
2875 // Dont need it any more
2876 pMac->ft.ftPEContext.pAddStaReq = NULL;
2877 return retCode;
2878}
2879
2880#endif /* WLAN_FEATURE_VOWIFI_11R */
2881
2882/**
2883 * limAddStaSelf()
2884 *
2885 *FUNCTION:
2886 * This function is called to add an STA context at hardware
2887 * whenever a STA is (Re) Associated.
2888 *
2889 *LOGIC:
2890 *
2891 *ASSUMPTIONS:
2892 * NA
2893 *
2894 *NOTE:
2895 * NA
2896 *
2897 * @param pMac - Pointer to Global MAC structure
2898 * @param pStaDs - Pointer to the STA datastructure created by
2899 * LIM and maintained by DPH
2900 * @return retCode - Indicates success or failure return code
2901 */
2902
2903tSirRetStatus
2904limAddStaSelf(tpAniSirGlobal pMac,tANI_U16 staIdx, tANI_U8 updateSta, tpPESession psessionEntry)
2905{
2906 tpAddStaParams pAddStaParams = NULL;
2907 tSirMsgQ msgQ;
2908 tSirRetStatus retCode = eSIR_SUCCESS;
2909 tSirMacAddr staMac;
2910 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
krunal soni71343fb2013-09-16 16:16:26 -07002911 tANI_U32 shortGi20MhzSupport;
2912 tANI_U32 shortGi40MhzSupport;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302913 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002914 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2915 * that cfg carries the systemwide capability that device under
2916 * consideration can support. This capability gets plumbed into the cfg
2917 * cache at system initialization time via the .dat and .ini file override
2918 * mechanisms and will not change. If it does change, it is the
2919 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2920 * command.*/
2921 tANI_U32 selfStaDot11Mode=0, selfTxWidth=0;
2922 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
2923 limLog( pMac, LOG1, FL("cfgDot11Mode %d"),(int)selfStaDot11Mode);
2924 wlan_cfgGetInt(pMac,WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,&selfTxWidth);
2925 limLog( pMac, LOG1, FL("SGI 20 %d"),(int)selfTxWidth);
2926 limLog( pMac, LOG1, FL("Roam Channel Bonding Mode %d"),(int)pMac->roam.configParam.uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002927
2928 #if 0
2929 retCode =wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2930 if (retCode != eSIR_SUCCESS)
2931 {
2932 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002933 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 return retCode;
2935 }
2936 #endif //TO SUPPORT BT-AMP
2937 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302938 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": "),MAC_ADDR_ARRAY(staMac));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302939 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2940 if (NULL == pAddStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302942 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 return eSIR_MEM_ALLOC_FAILED;
2944 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302945 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002946
2947 /// Add STA context at MAC HW (BMU, RHP & TFP)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302948 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2949 (tANI_U8 *) staMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002950
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302951 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2952 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
2954 pAddStaParams->assocId = psessionEntry->limAID;
2955 pAddStaParams->staType = STA_ENTRY_SELF;
2956 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2957 pAddStaParams->respReqd = 1;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302958 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 /* Update PE session ID */
2960 pAddStaParams->sessionId = psessionEntry->peSessionId;
2961
2962 // This will indicate HAL to "allocate" a new STA index
2963 pAddStaParams->staIdx = staIdx;
2964 pAddStaParams->updateSta = updateSta;
2965
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302966 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
2967 {
2968 limLog(pMac, LOGP, FL("Get short preamble failed. Set Default value"));
2969 pAddStaParams->shortPreambleSupported = 1;
2970 }
2971 pAddStaParams->shortPreambleSupported = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002972
Jeff Johnsone7245742012-09-05 17:12:55 -07002973#ifdef WLAN_FEATURE_11AC
2974 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry,NULL);
2975#else
2976 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
2977#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002978// if( psessionEntry->htCapability)---> old check
2979 /*We used to check if the session is htCapable before setting the htCapable
2980 * flag. The check limited us from operating */
2981 if ( IS_DOT11_MODE_HT(selfStaDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002983 pAddStaParams->htCapable = TRUE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002984#ifdef DISABLE_GF_FOR_INTEROP
2985 /*
2986 * To resolve the interop problem with Broadcom AP,
2987 * where TQ STA could not pass traffic with GF enabled,
2988 * TQ STA will do Greenfield only with TQ AP, for
2989 * everybody else it will be turned off.
2990 */
2991 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2992 {
2993 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2994 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2995 }
2996 else
2997#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002998 {
2999 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
3000 pAddStaParams->txChannelWidthSet =
3001 pMac->roam.configParam.channelBondingMode5GHz;
3002 // pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
3003 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
3004 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
3005 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
3006 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
3007 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
3008 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
3009 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
3010 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
krunal soni71343fb2013-09-16 16:16:26 -07003011 /*
3012 * We will read the gShortGI20Mhz from ini file, and if it is set
3013 * to 1 then we will tell Peer that we support 40Mhz short GI
3014 */
3015 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3016 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3017 &shortGi20MhzSupport)))
3018 {
3019 if (VOS_TRUE == shortGi20MhzSupport)
3020 {
3021 pAddStaParams->fShortGI20Mhz =
3022 WNI_CFG_SHORT_GI_20MHZ_STAMAX;
3023 //pAddStaParams->fShortGI20Mhz =
3024 //limGetHTCapability(pMac, eHT_SHORT_GI_20MHZ,
3025 // psessionEntry);
3026 }
3027 else
3028 {
3029 pAddStaParams->fShortGI20Mhz = VOS_FALSE;
3030 }
3031 }
3032 else
3033 {
3034 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3035 "CFG,setting value to default"));)
3036 pAddStaParams->fShortGI20Mhz = WNI_CFG_SHORT_GI_20MHZ_STADEF;
3037 }
3038
3039 /*
3040 * We will read the gShortGI40Mhz from ini file, and if it is set
3041 * to 1 then we will tell Peer that we support 40Mhz short GI
3042 */
3043 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3044 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3045 &shortGi40MhzSupport)))
3046 {
3047 if (VOS_TRUE == shortGi40MhzSupport)
3048 {
3049 pAddStaParams->fShortGI40Mhz =
3050 WNI_CFG_SHORT_GI_40MHZ_STAMAX;
3051 //pAddStaParams->fShortGI40Mhz =
3052 //limGetHTCapability(pMac, eHT_SHORT_GI_40MHZ,
3053 // psessionEntry);
3054 }
3055 else
3056 {
3057 pAddStaParams->fShortGI40Mhz = VOS_FALSE;
3058 }
3059 }
3060 else
3061 {
3062 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3063 "CFG,setting value to default"));)
3064 pAddStaParams->fShortGI40Mhz = WNI_CFG_SHORT_GI_40MHZ_STADEF;
3065 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303066 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303067 "maxAmpduSize = %d"), pAddStaParams->greenFieldCapable,
3068 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
3069
Abhishek Singh525045c2014-12-15 17:18:45 +05303070 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303071 "fShortGI40Mhz: %d lsigTxopProtection: %d"),
3072 pAddStaParams->fDsssCckMode40Mhz, pAddStaParams->fShortGI20Mhz,
3073 pAddStaParams->fShortGI40Mhz, pAddStaParams->lsigTxopProtection);
3074
Abhishek Singh525045c2014-12-15 17:18:45 +05303075 limLog(pMac, LOG1, FL(" maxAmsduSize: %d txChannelWidthSet: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303076 "mimoPS: %d rifsMode %d delBASupport %d"),
3077 pAddStaParams->maxAmsduSize,
3078 pAddStaParams->txChannelWidthSet, pAddStaParams->mimoPS,
3079 pAddStaParams->rifsMode, pAddStaParams->delBASupport );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003082#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003083 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
3084 if (pAddStaParams->vhtCapable){
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003085 pAddStaParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003086 limLog( pMac, LOG1, FL("VHT WIDTH SET %d"),pAddStaParams->vhtTxChannelWidthSet);
3087 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08003088 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Abhishek Singh525045c2014-12-15 17:18:45 +05303089 limLog(pMac, LOG1, FL("vhtCapable: %d vhtTxBFCapable %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303090 pAddStaParams->vhtCapable, pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003091#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003092
3093 /* For Self STA get the LDPC capability from session i.e config.ini*/
3094 pAddStaParams->htLdpcCapable =
3095 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
3096 pAddStaParams->vhtLdpcCapable =
3097 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
3098
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003100 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
3102
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3104 {
3105 pAddStaParams->p2pCapableSta = 1;
3106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003107
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003108 //limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
3109 pAddStaParams->supportedRates.opRateMode = limGetStaRateMode((tANI_U8)selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003110
Abhishek Singh525045c2014-12-15 17:18:45 +05303111 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303112 pAddStaParams->staIdx,pAddStaParams->updateSta,
3113 pAddStaParams->htCapable);
3114
Abhishek Singh525045c2014-12-15 17:18:45 +05303115 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303116 "p2pCapableSta: %d"),
3117 pAddStaParams->htLdpcCapable,pAddStaParams->vhtLdpcCapable,
3118 pAddStaParams->p2pCapableSta);
3119
Abhishek Singh525045c2014-12-15 17:18:45 +05303120 limLog(pMac, LOG1, FL(" sessionid: %d Assoc ID: %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303121 " shortPreambleSupported: %d "), psessionEntry->smeSessionId,
3122 pAddStaParams->assocId, pAddStaParams->listenInterval,
3123 pAddStaParams->shortPreambleSupported);
3124
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 msgQ.type = WDA_ADD_STA_REQ;
3126 //
3127 // FIXME_GEN4
3128 // A global counter (dialog token) is required to keep track of
3129 // all PE <-> HAL communication(s)
3130 //
3131 msgQ.reserved = 0;
3132 msgQ.bodyptr = pAddStaParams;
3133 msgQ.bodyval = 0;
3134
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303135 limLog( pMac, LOGW, FL(MAC_ADDRESS_STR":Sessionid %d : "
3136 "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ),
3137 MAC_ADDR_ARRAY(pAddStaParams->staMac),
3138 pAddStaParams->sessionId,
3139 pAddStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07003140 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003141
3142 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3143 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003144 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303145 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 }
3147 return retCode;
3148}
3149
3150
3151/**
3152 * limTeardownInfraBSS()
3153 *
3154 *FUNCTION:
3155 * This function is called by various LIM functions to teardown
3156 * an established Infrastructure BSS
3157 *
3158 *LOGIC:
3159 *
3160 *ASSUMPTIONS:
3161 *
3162 *NOTE:
3163 *
3164 * @param pMac - Pointer to Global MAC structure
3165 * @return None
3166 */
3167
3168void
3169limTeardownInfraBss(tpAniSirGlobal pMac,tpPESession psessionEntry)
3170{
3171 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3172
3173 /**
3174 * Send Broadcast Disassociate frame with
3175 * 'leaving BSS' reason.
3176 */
3177 limSendDisassocMgmtFrame(pMac,
3178 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003179 bcAddr,psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003180} /*** end limTeardownInfraBss() ***/
3181
3182
3183/**
3184 * limHandleCnfWaitTimeout()
3185 *
3186 *FUNCTION:
3187 * This function is called by limProcessMessageQueue to handle
3188 * various confirmation failure cases.
3189 *
3190 *LOGIC:
3191 *
3192 *ASSUMPTIONS:
3193 *
3194 *NOTE:
3195 *
3196 * @param pMac - Pointer to Global MAC structure
3197 * @param pStaDs - Pointer to a sta descriptor
3198 * @return None
3199 */
3200
3201void limHandleCnfWaitTimeout(tpAniSirGlobal pMac, tANI_U16 staId)
3202{
3203 tpDphHashNode pStaDs;
3204 tLimSystemRole systemRole;
3205 tpPESession psessionEntry = NULL;
3206
3207 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId))== NULL)
3208 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003209 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 return;
3211 }
3212 systemRole = limGetSystemRole(psessionEntry);
3213 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
3214
3215 if (pStaDs == NULL)
3216 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003217 PELOGW(limLog(pMac, LOGW, FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 return;
3219 }
3220
3221 switch (pStaDs->mlmStaContext.mlmState) {
3222 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003223 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 -07003224 limPrintMacAddr(pMac, pStaDs->staAddr, LOGW);
3225
3226 if ( (systemRole == eLIM_AP_ROLE)|| (systemRole == eLIM_BT_AMP_AP_ROLE) )
3227 {
3228 limRejectAssociation(
3229 pMac,
3230 pStaDs->staAddr,
3231 pStaDs->mlmStaContext.subType,
3232 true,
3233 pStaDs->mlmStaContext.authType,
3234 pStaDs->assocId,
3235 true,
3236 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
3237 psessionEntry);
3238 }
3239 break;
3240
3241 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003242 limLog(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 pStaDs->mlmStaContext.mlmState);
3244 }
3245}
3246
3247
3248/**
3249 * limDeleteDphHashEntry()
3250 *
3251 *FUNCTION:
3252 * This function is called whenever we need to delete
3253 * the dph hash entry
3254 *
3255 *LOGIC:
3256 *
3257 *ASSUMPTIONS:
3258 *
3259 *NOTE:
3260 *
3261 * @param pMac Pointer to Global MAC structure
3262 * @param tANI_U16 staId
3263 * @return None
3264 */
3265
3266void
3267limDeleteDphHashEntry(tpAniSirGlobal pMac, tSirMacAddr staAddr, tANI_U16 staId,tpPESession psessionEntry)
3268{
3269 tANI_U16 aid;
3270 tpDphHashNode pStaDs;
3271 tUpdateBeaconParams beaconParams;
3272 tLimSystemRole systemRole;
3273
Kaushik, Sushantfb156732014-01-07 15:36:03 +05303274 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 beaconParams.paramChangeBitmap = 0;
3276 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, staId);
3277 if (NULL == psessionEntry)
3278 {
3279 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
3280 return;
3281 }
3282 systemRole = limGetSystemRole(psessionEntry);
3283 beaconParams.bssIdx = psessionEntry->bssIdx;
3284 pStaDs = dphLookupHashEntry(pMac, staAddr, &aid, &psessionEntry->dph.dphHashTable);
3285 if (pStaDs != NULL)
3286 {
3287 PELOGW(limLog(pMac, LOGW, FL("Deleting DPH Hash entry for STAID: %X\n "), staId);)
3288 // update the station count and perform associated actions
3289 // do this before deleting the dph hash entry
3290 limUtilCountStaDel(pMac, pStaDs, psessionEntry);
3291
3292 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||
3293 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
3294 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
3296 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE){
3297 limDecideApProtectionOnDelete(pMac, pStaDs, &beaconParams,psessionEntry);
3298 }
3299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003300
3301 if(eLIM_STA_IN_IBSS_ROLE == systemRole)
3302 limIbssDecideProtectionOnDelete(pMac, pStaDs, &beaconParams, psessionEntry);
3303
3304 limDecideShortPreamble(pMac, pStaDs, &beaconParams, psessionEntry);
3305 limDecideShortSlot(pMac, pStaDs, &beaconParams, psessionEntry);
3306
3307 //Send message to HAL about beacon parameter change.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003308 PELOGW(limLog(pMac, LOGW, FL("param bitmap = %d "), beaconParams.paramChangeBitmap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 if(beaconParams.paramChangeBitmap)
3310 {
3311 schSetFixedBeaconFields(pMac,psessionEntry);
3312 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
3313 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08003314
3315#ifdef WLAN_FEATURE_11W
3316 tx_timer_delete(&pStaDs->pmfSaQueryTimer);
3317#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 }
3319 if (dphDeleteHashEntry(pMac, staAddr, staId, &psessionEntry->dph.dphHashTable) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003320 limLog(pMac, LOGP, FL("error deleting hash entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 }
3322}
3323
3324
3325
3326/**
3327 * limCheckAndAnnounceJoinSuccess()
3328 *
3329 *FUNCTION:
3330 * This function is called upon receiving Beacon/Probe Response
3331 * frame in WT_JOIN_BEACON_STATE to check if the received
3332 * Beacon/Probe Response is from the BSS that we're attempting
3333 * to join.
3334 *
3335 *LOGIC:
3336 * If the Beacon/Probe Response is indeed from the BSS we're
3337 * attempting to join, join success is sent to SME.
3338 *
3339 *ASSUMPTIONS:
3340 *
3341 *NOTE:
3342 *
3343 * @param pMac Pointer to Global MAC structure
3344 * @param pBPR Pointer to received Beacon/Probe Response
3345 * @param pHdr Pointer to received Beacon/Probe Response
3346 * MAC header
3347 * @return None
3348 */
3349
3350void
3351limCheckAndAnnounceJoinSuccess(tpAniSirGlobal pMac,
3352 tSirProbeRespBeacon *pBPR,
3353 tpSirMacMgmtHdr pHdr,tpPESession psessionEntry)
3354{
3355 tSirMacSSid currentSSID;
3356 tLimMlmJoinCnf mlmJoinCnf;
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003357 tANI_U32 val = 0;
3358 tANI_U32 *noa1DurationFromBcn = NULL;
3359 tANI_U32 *noa2DurationFromBcn = NULL;
3360 tANI_U32 noa;
3361 tANI_U32 TotalNum_NoADesc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003362
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303363 vos_mem_copy(currentSSID.ssId,
3364 psessionEntry->ssId.ssId,
3365 psessionEntry->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003366
3367 currentSSID.length = (tANI_U8)psessionEntry->ssId.length ;
3368
3369 if (
3370 /* Check for SSID only in probe response. Beacons may not carry
3371 SSID information in hidden SSID case */
3372 ( (SIR_MAC_MGMT_FRAME == pHdr->fc.type) &&
3373 (SIR_MAC_MGMT_PROBE_RSP == pHdr->fc.subType) ) &&
3374 currentSSID.length &&
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303375 (!vos_mem_compare((tANI_U8 *) &pBPR->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 (tANI_U8 *) &currentSSID,
3377 (tANI_U8) (1 + currentSSID.length)) ))
3378 {
3379 /**
3380 * Received SSID does not match with the one we've.
3381 * Ignore received Beacon frame
3382 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303383 limLog(pMac, LOG1, FL("SSID received in Beacon does not match"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003384#ifdef WLAN_DEBUG
3385 pMac->lim.gLimBcnSSIDMismatchCnt++;
3386#endif
3387 return;
3388 }
3389
3390 if( (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_STA_ROLE))
3391 {
Nirav Shahbc35fb72013-12-12 18:14:06 +05303392 limLog(pMac, LOG1, FL("Received Beacon/PR with matching BSSID"
3393 MAC_ADDRESS_STR "PESessionID %d"),
3394 MAC_ADDR_ARRAY(psessionEntry->bssId),
3395 psessionEntry->peSessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 // Deactivate Join Failure timer
3397 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003398 // Deactivate Periodic Join timer
3399 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07003400
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003401 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona &&
3402 pBPR->P2PProbeRes.NoticeOfAbsence.present)
3403 {
3404
3405 noa1DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3406
3407 if(pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3408 TotalNum_NoADesc = pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc/SIZE_OF_NOA_DESCRIPTOR;
3409
3410 noa = *noa1DurationFromBcn;
3411
3412 if(TotalNum_NoADesc > 1)
3413 {
3414 noa2DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + SIZE_OF_NOA_DESCRIPTOR + 1);
3415 noa += *noa2DurationFromBcn;
3416 }
3417
3418 /*If MAX Noa exceeds 3 secs we will consider only 3 secs to
3419 * avoid arbitary values in noa duration field
3420 */
3421 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ? MAX_NOA_PERIOD_IN_MICROSECS : noa;
3422 noa = noa/1000; //Convert to ms
3423
3424 if( wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,&val) == eSIR_SUCCESS )
3425 {
3426 psessionEntry->defaultAuthFailureTimeout = val;
3427 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,val + noa, NULL, eANI_BOOLEAN_FALSE);
3428 }
3429 }
3430 else
3431 {
3432 psessionEntry->defaultAuthFailureTimeout = 0;
3433 }
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003434
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 // Update Beacon Interval at CFG database
3436
3437 if ( pBPR->HTCaps.present )
3438 limUpdateStaRunTimeHTCapability( pMac, &pBPR->HTCaps );
3439 if ( pBPR->HTInfo.present )
3440 limUpdateStaRunTimeHTInfo( pMac, &pBPR->HTInfo, psessionEntry);
3441 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003442 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003443
Ganesh Kondabattiniaad38d92014-11-19 17:06:00 +05303444 /* update the capability info based on recently
3445 * received beacon/probe response frame */
3446 psessionEntry->limCurrentBssCaps = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003447
3448 /**
3449 * Announce join success by sending
3450 * Join confirm to SME.
3451 */
3452 mlmJoinCnf.resultCode = eSIR_SME_SUCCESS;
3453 mlmJoinCnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3454 /* Update PE sessionId*/
3455 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3456 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3457 } // if ((pMac->lim.gLimSystemRole == IBSS....
Abhishek Singh74037df2017-07-20 11:08:56 +05303458
3459 /* Update HS 2.0 Information Element */
3460 sir_copy_hs20_ie(&psessionEntry->hs20vendor_ie, &pBPR->hs20vendor_ie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003461}
3462
3463/**
3464 * limExtractApCapabilities()
3465 *
3466 *FUNCTION:
3467 * This function is called to extract all of the AP's capabilities
3468 * from the IEs received from it in Beacon/Probe Response frames
3469 *
3470 *LOGIC:
3471 * This routine mimics the limExtractApCapability() API. The difference here
3472 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3473 * left to the caller of this API to use this info as required
3474 *
3475 *ASSUMPTIONS:
3476 * NA
3477 *
3478 *NOTE:
3479 *
3480 * @param pMac Pointer to Global MAC structure
3481 * @param pIE Pointer to starting IE in Beacon/Probe Response
3482 * @param ieLen Length of all IEs combined
3483 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3484 * populated
3485 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3486 */
3487tSirRetStatus limExtractApCapabilities( tpAniSirGlobal pMac,
3488 tANI_U8 *pIE,
3489 tANI_U16 ieLen,
3490 tpSirProbeRespBeacon beaconStruct )
3491{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303492 vos_mem_set((tANI_U8 *) beaconStruct, sizeof( tSirProbeRespBeacon ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003493
3494 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003495 FL( "In limExtractApCapabilities: The IE's being received are:" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
3497
3498 // Parse the Beacon IE's, Don't try to parse if we dont have anything in IE
3499 if (ieLen > 0) {
3500 if( eSIR_SUCCESS != sirParseBeaconIE( pMac, beaconStruct, pIE, (tANI_U32)ieLen ))
3501 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003502 limLog( pMac, LOGE, FL("APCapExtract: Beacon parsing error!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 return eSIR_FAILURE;
3504 }
3505 }
3506
3507 return eSIR_SUCCESS;
3508}
3509
3510
3511/**
3512 * limDelBss()
3513 *
3514 *FUNCTION:
3515 * This function is called to delete BSS context at hardware
3516 * whenever a STA is disassociated
3517 *
3518 *LOGIC:
3519 *
3520 *ASSUMPTIONS:
3521 * NA
3522 *
3523 *NOTE:
3524 * NA
3525 *
3526 * @param pMac - Pointer to Global MAC structure
3527 * @param pStaDs - Pointer to the STA datastructure created by
3528 * LIM and maintained by DPH
3529 * @return retCode - Indicates success or failure return code
3530 */
3531
3532tSirRetStatus
3533limDelBss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tANI_U16 bssIdx,tpPESession psessionEntry)
3534{
3535 tpDeleteBssParams pDelBssParams = NULL;
3536 tSirMsgQ msgQ;
3537 tSirRetStatus retCode = eSIR_SUCCESS;
3538
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303539 pDelBssParams = vos_mem_malloc(sizeof(tDeleteBssParams));
3540 if (NULL == pDelBssParams)
3541 {
3542 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 return eSIR_MEM_ALLOC_FAILED;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303544 }
3545 vos_mem_set((tANI_U8 *) pDelBssParams, sizeof(tDeleteBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003546
3547
3548 pDelBssParams->sessionId = psessionEntry->peSessionId; //update PE session Id
3549
3550 //DPH was storing the AssocID in staID field,
3551 //staID is actually assigned by HAL when AddSTA message is sent.
3552 if (pStaDs != NULL)
3553 {
3554 pDelBssParams->bssIdx= pStaDs->bssId;
3555 pStaDs->valid = 0;
3556 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3557 }
3558 else
3559 pDelBssParams->bssIdx = bssIdx;
3560 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003561 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003562
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07003563 if((psessionEntry->peSessionId == pMac->lim.limTimers.gLimJoinFailureTimer.sessionId) &&
3564 (VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)))
3565 {
3566 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
3567 }
3568
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 pDelBssParams->status= eHAL_STATUS_SUCCESS;
3570 pDelBssParams->respReqd = 1;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303571
3572 PELOGW(limLog( pMac, LOGW, FL("Sessionid %d : Sending HAL_DELETE_BSS_REQ "
3573 "for bss idx: %X BSSID:"MAC_ADDRESS_STR), pDelBssParams->sessionId,
3574 pDelBssParams->bssIdx,
3575 MAC_ADDR_ARRAY(psessionEntry->bssId));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003576
3577 //we need to defer the message until we get the response back from HAL.
3578 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3579
3580 msgQ.type = WDA_DELETE_BSS_REQ;
3581 msgQ.reserved = 0;
3582 msgQ.bodyptr = pDelBssParams;
3583 msgQ.bodyval = 0;
3584
Jeff Johnsone7245742012-09-05 17:12:55 -07003585 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003586
3587 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3588 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003589 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003590 limLog( pMac, LOGE, FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303591 vos_mem_free(pDelBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 }
3593
3594 return retCode;
3595}
3596
3597
Jeff Johnson295189b2012-06-20 16:38:30 -07003598
3599/**
3600 * limSendAddBss()
3601 *
3602 *FUNCTION:
3603 *
3604 *LOGIC:
3605 * 1) LIM receives eWNI_SME_JOIN_REQ
3606 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3607 * SIR_HAL_ADD_BSS_REQ to HAL
3608 *
3609 *ASSUMPTIONS:
3610 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3611 * ADD BSS parameters can be obtained from two sources:
3612 * 1) pMac->lim.gLimMlmJoinReq
3613 * 2) beaconStruct, passed as paramter
3614 * So, if a reqd parameter is found in bssDescriptions
3615 * then it is given preference over beaconStruct
3616 *
3617 *NOTE:
3618 *
3619 * @param pMac Pointer to Global MAC structure
3620 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3621 * beaconstruct Has the ProbeRsp/Beacon structured details
3622 * bssDescription bssDescription passed to PE from the SME
3623 * @return None
3624 */
3625
3626tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3627 tpSchBeaconStruct pBeaconStruct, tpSirBssDescription bssDescription, tANI_U8 updateEntry,
3628 tpPESession psessionEntry)
3629
3630{
3631 tSirMsgQ msgQ;
3632 tpAddBssParams pAddBssParams = NULL;
3633 tANI_U32 retCode;
3634 tANI_U8 i;
3635 tpDphHashNode pStaDs = NULL;
3636 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003637 tANI_U32 shortGi20MhzSupport;
3638 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303640 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
3641 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 {
3643 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303644 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 retCode = eSIR_MEM_ALLOC_FAILED;
3646 goto returnFailure;
3647 }
3648 else
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303649 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003650
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303651 vos_mem_copy(pAddBssParams->bssId,bssDescription->bssId,
3652 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303654 vos_mem_copy(pAddBssParams->selfMacAddr,
3655 psessionEntry->selfMacAddr,
3656 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303657
3658 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
3659 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
3660
3661 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
3662 MAC_ADDR_ARRAY(pAddBssParams->bssId));
3663
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3665 {
3666 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3667 }
3668 else
3669 {
3670 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3671 }
3672
3673 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3674
3675 /* Update PE session ID */
3676 pAddBssParams->sessionId = psessionEntry->peSessionId;
3677
3678 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3679
3680 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3681 pAddBssParams->updateBss = updateEntry;
3682
3683
3684 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3685 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3686 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3687 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
3688
3689 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303690 vos_mem_copy(pAddBssParams->rateSet.rate,
3691 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003692
3693 pAddBssParams->nwType = bssDescription->nwType;
3694
Jeff Johnsone7245742012-09-05 17:12:55 -07003695 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3697 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3698 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3699 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3700
Abhishek Singh525045c2014-12-15 17:18:45 +05303701 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303702 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
3703 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
3704
Abhishek Singh525045c2014-12-15 17:18:45 +05303705 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303706 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
3707 pAddBssParams->cfParamSet.cfpMaxDuration,
3708 pAddBssParams->cfParamSet.cfpDurRemaining,
3709 pAddBssParams->rateSet.numRates);
3710
Abhishek Singh525045c2014-12-15 17:18:45 +05303711 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303712 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
3713 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
3714 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
3715 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07003716
3717 // Use the advertised capabilities from the received beacon/PR
3718
3719
3720 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3721 {
3722 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05303723 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 if ( pBeaconStruct->HTInfo.present )
3725 {
3726 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pAssocRsp->HTInfo.opMode;
3727 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pAssocRsp->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3730 (chanWidthSupp) )
3731 {
3732 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3733 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3734 }
3735 else
3736 {
3737 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003738 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 }
3740 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3741 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3742 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303743
Abhishek Singh525045c2014-12-15 17:18:45 +05303744 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303745 "txChannelWidthSet: %d currentExtChannel: %d "),
3746 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
3747 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
3748
Abhishek Singh525045c2014-12-15 17:18:45 +05303749 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303750 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
3751 pAddBssParams->llnNonGFCoexist,
3752 pAddBssParams->fLsigTXOPProtectionFullSupport,
3753 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 }
3755 }
3756
3757 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05303758 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303759 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003760#ifdef WLAN_FEATURE_11AC
3761 if (psessionEntry->vhtCapability && ( pAssocRsp->VHTCaps.present ))
3762 {
3763 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3764 pAddBssParams->vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth;
3765 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003766 pAddBssParams->currentOperChannel,
3767 pAddBssParams->currentExtChannel,
3768 psessionEntry->apCenterChan,
3769 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003770 }
3771 else
3772 {
3773 pAddBssParams->vhtCapable = 0;
3774 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303775 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303776 "currentExtChannel %d"),pAddBssParams->vhtCapable,
3777 pAddBssParams->vhtTxChannelWidthSet,
3778 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003779#endif
3780
3781
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 // Populate the STA-related parameters here
3783 // Note that the STA here refers to the AP
3784 {
3785 /* staType = PEER*/
3786 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3787
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303788 vos_mem_copy(pAddBssParams->staContext.bssId,
3789 bssDescription->bssId,
3790 sizeof( tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3792
3793 /* Fill Assoc id from the dph table */
3794 pStaDs = dphLookupHashEntry(pMac, pAddBssParams->staContext.bssId,
3795 &pAddBssParams->staContext.assocId, &psessionEntry->dph.dphHashTable);
3796 if (pStaDs == NULL)
3797 {
Arif Hussain24bafea2013-11-15 15:10:03 -08003798 PELOGE(limLog(pMac, LOGE, FL("Couldn't get assoc id for "
3799 "MAC ADDR: " MAC_ADDRESS_STR),
3800 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 }
3802 pAddBssParams->staContext.uAPSD = 0;
3803 pAddBssParams->staContext.maxSPLen = 0;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05303804 pAddBssParams->staContext.shortPreambleSupported =
3805 psessionEntry->beaconParams.fShortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 pAddBssParams->staContext.updateSta = updateEntry;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303807
Abhishek Singh525045c2014-12-15 17:18:45 +05303808 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303809 " shortPreambleSupported: %d"),
3810 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
3811 pAddBssParams->staContext.shortPreambleSupported);
3812
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003813 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 {
3815 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3816 pAddBssParams->staContext.htCapable = 1;
3817 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3818 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05303819 limLog(pMac, LOG1,FL("StaContext htCapable: %d greenFieldCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303820 "lsigTxopProtection: %d"), pAddBssParams->staContext.htCapable,
3821 pAddBssParams->staContext.greenFieldCapable,
3822 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003823#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05303824 if (psessionEntry->vhtCapability &&
3825 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003826 {
3827 pAddBssParams->staContext.vhtCapable = 1;
3828 if ((pAssocRsp->VHTCaps.suBeamFormerCap ||
3829 pAssocRsp->VHTCaps.muBeamformerCap) &&
3830 psessionEntry->txBFIniFeatureEnabled)
3831 {
3832 pAddBssParams->staContext.vhtTxBFCapable = 1;
3833 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303834 if (pAssocRsp->VHTCaps.muBeamformerCap &&
3835 psessionEntry->txMuBformee )
3836 {
3837 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
3838 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
3839 /* Dont allow any other MuBf session as concurrency
3840 * is not supported
3841 */
3842 pMac->isMuBfsessionexist = TRUE;
3843 }
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003844 }
3845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3847 (chanWidthSupp) )
3848 {
3849 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003850#ifdef WLAN_FEATURE_11AC
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003851 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003852 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003853 pAddBssParams->staContext.vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth; //pMac->lim.apChanWidth;
3854 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303855 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303856 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
3857 pAddBssParams->staContext.vhtCapable,
3858 pAddBssParams->staContext.vhtTxChannelWidthSet,
3859 pAddBssParams->staContext.vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 }
3862 else
3863 {
3864 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3865 }
3866 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pAssocRsp->HTCaps.mimoPowerSave;
3867 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3868 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3869 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3870 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003871 /*
3872 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3873 * if they are set then we will use what ever Assoc response coming
3874 * from AP supports. If these values are set as 0 in ini file then
3875 * we will hardcode this values to 0.
3876 */
3877 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3878 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3879 &shortGi20MhzSupport)))
3880 {
3881 if (VOS_TRUE == shortGi20MhzSupport)
3882 {
3883 pAddBssParams->staContext.fShortGI20Mhz =
3884 (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3885 }
3886 else
3887 {
3888 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3889 }
3890 }
3891 else
3892 {
3893 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3894 "CFG,setting value to default"));)
3895 pAddBssParams->staContext.fShortGI20Mhz =
3896 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3897 }
3898
3899 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3900 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3901 &shortGi40MhzSupport)))
3902 {
3903 if (VOS_TRUE == shortGi40MhzSupport)
3904 {
3905 pAddBssParams->staContext.fShortGI40Mhz =
3906 (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3907 }
3908 else
3909 {
3910 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3911 }
3912 }
3913 else
3914 {
3915 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3916 "CFG,setting value to default"));)
3917 pAddBssParams->staContext.fShortGI40Mhz =
3918 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3919 }
3920
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05303922 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003923 {
3924 pAddBssParams->staContext.htLdpcCapable = 0;
3925 pAddBssParams->staContext.vhtLdpcCapable = 0;
3926 }
3927 else
3928 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05303929 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
3930 pAddBssParams->staContext.htLdpcCapable =
3931 (tANI_U8)pAssocRsp->HTCaps.advCodingCap;
3932 else
3933 pAddBssParams->staContext.htLdpcCapable = 0;
3934 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
3935 pAddBssParams->staContext.vhtLdpcCapable =
3936 (tANI_U8)pAssocRsp->VHTCaps.ldpcCodingCap;
3937 else
3938 pAddBssParams->staContext.vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003939 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003940
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 if( pBeaconStruct->HTInfo.present )
3942 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303943
Abhishek Singh525045c2014-12-15 17:18:45 +05303944 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303945 " delBASupport: %d maxAmsduSize: %d"),
3946 pAddBssParams->staContext.txChannelWidthSet,
3947 pAddBssParams->staContext.mimoPS,
3948 pAddBssParams->staContext.delBASupport,
3949 pAddBssParams->staContext.maxAmsduSize);
3950
Abhishek Singh525045c2014-12-15 17:18:45 +05303951 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303952 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
3953 pAddBssParams->staContext.fDsssCckMode40Mhz,
3954 pAddBssParams->staContext.fShortGI20Mhz);
3955
Abhishek Singh525045c2014-12-15 17:18:45 +05303956 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303957 "htLdpcCapable: %d vhtLdpcCapable: %d"),
3958 pAddBssParams->staContext.fShortGI40Mhz,
3959 pAddBssParams->staContext.maxAmpduSize,
3960 pAddBssParams->staContext.htLdpcCapable,
3961 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 }
3963
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303964 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3965 if ((psessionEntry->limWmeEnabled && (pAssocRsp->wmeEdcaPresent || pAddBssParams->htCapable)) ||
3966 (psessionEntry->limQosEnabled && (pAssocRsp->edcaPresent || pAddBssParams->htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 pAddBssParams->staContext.wmmEnabled = 1;
3968 else
3969 pAddBssParams->staContext.wmmEnabled = 0;
3970
3971 //Update the rates
3972
3973 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3974 if (pStaDs != NULL)
3975 {
3976 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303977 vos_mem_copy((tANI_U8*)&pAddBssParams->staContext.supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 (tANI_U8*)&pStaDs->supportedRates,
3979 sizeof(tSirSupportedRates));
3980 }
3981 else
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003982 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003983
3984 }
3985
3986 //Disable BA. It will be set as part of ADDBA negotiation.
3987 for( i = 0; i < STACFG_MAX_TC; i++ )
3988 {
3989 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3990 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3991 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3992 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3993 }
3994
3995 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
3996
3997#if defined WLAN_FEATURE_VOWIFI
3998 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05303999 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304000 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07004001#endif
4002 // FIXME_GEN4 - Any other value that can be used for initialization?
4003 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4004 pAddBssParams->respReqd = true;
4005
4006 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4007
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
4009 {
4010 pAddBssParams->staContext.p2pCapableSta = 1;
4011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004012
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004013 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004014
4015#if defined WLAN_FEATURE_VOWIFI_11R
4016 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05304017 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304018 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004019#endif
4020
Chet Lanctot186b5732013-03-18 10:26:30 -07004021#ifdef WLAN_FEATURE_11W
4022 if (psessionEntry->limRmfEnabled)
4023 {
4024 pAddBssParams->rmfEnabled = 1;
4025 pAddBssParams->staContext.rmfEnabled = 1;
4026 }
4027#endif
4028
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 // Set a new state for MLME
4030 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
4031 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
4032 else
4033 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Abhishek Singh2fefebd2016-01-13 14:37:49 +05304034
Jeff Johnsone7245742012-09-05 17:12:55 -07004035 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004036
Abhishek Singh525045c2014-12-15 17:18:45 +05304037 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304038 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
4039 pAddBssParams->staContext.encryptType,
4040 pAddBssParams->staContext.p2pCapableSta);
4041
Abhishek Singh525045c2014-12-15 17:18:45 +05304042 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304043 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
4044 pAddBssParams->halPersona, psessionEntry->limMlmState);
4045
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 //we need to defer the message until we get the response back from HAL.
4047 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4048
4049 msgQ.type = WDA_ADD_BSS_REQ;
4050 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4051 msgQ.reserved = 0;
4052 msgQ.bodyptr = pAddBssParams;
4053 msgQ.bodyval = 0;
4054
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05304055 limLog( pMac, LOG1, FL("SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
4056 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004057 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004058
4059 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4060 if( eSIR_SUCCESS != retCode)
4061 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004062 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304063 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004064 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 retCode );
4066 goto returnFailure;
4067
4068 }
4069 else
4070 return retCode;
4071
4072 returnFailure:
4073 // Clean-up will be done by the caller...
4074 return retCode;
4075}
4076
4077
4078
4079
4080tSirRetStatus limStaSendAddBssPreAssoc( tpAniSirGlobal pMac, tANI_U8 updateEntry, tpPESession psessionEntry)
4081{
4082 tSirMsgQ msgQ;
4083 tpAddBssParams pAddBssParams = NULL;
4084 tANI_U32 retCode;
4085 tANI_U8 i;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004086 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07004088 tANI_U32 shortGi20MhzSupport;
4089 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 tpSirBssDescription bssDescription = &psessionEntry->pLimJoinReq->bssDescription;
4091
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304092 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
4093 if (NULL == pBeaconStruct)
Jeff Johnson32d95a32012-09-10 13:15:23 -07004094 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304095 limLog(pMac, LOGE, FL("Unable to allocate memory during ADD_BSS") );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004096 return eSIR_MEM_ALLOC_FAILED;
4097 }
4098
Jeff Johnson295189b2012-06-20 16:38:30 -07004099
4100 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304101 pAddBssParams = vos_mem_malloc(sizeof(tAddBssParams));
4102 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 {
4104 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304105 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 retCode = eSIR_MEM_ALLOC_FAILED;
4107 goto returnFailure;
4108 }
4109
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304110 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004111
4112
4113 limExtractApCapabilities( pMac,
4114 (tANI_U8 *) bssDescription->ieFields,
Abhishek Singhbad2b322016-10-21 11:22:33 +05304115 GET_IE_LEN_IN_BSS(bssDescription->length),
Jeff Johnson32d95a32012-09-10 13:15:23 -07004116 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07004117
4118 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson32d95a32012-09-10 13:15:23 -07004119 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304120 vos_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
4121 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004122
4123 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304124 vos_mem_copy(pAddBssParams->selfMacAddr,
4125 psessionEntry->selfMacAddr,
4126 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304127 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
4128 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004129
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304130 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
4131 MAC_ADDR_ARRAY(pAddBssParams->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304133 * top of an already established Infra link. This lead to issues in
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 * concurrent data transfer.
4135 */
4136
4137 pAddBssParams->bssType = psessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
4138 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
4139
4140 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
4141
Jeff Johnson32d95a32012-09-10 13:15:23 -07004142 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 pAddBssParams->updateBss = updateEntry;
4144
4145
Jeff Johnson32d95a32012-09-10 13:15:23 -07004146 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
4147 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
4148 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
4149 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -07004150
4151
Jeff Johnson32d95a32012-09-10 13:15:23 -07004152 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304153 vos_mem_copy(pAddBssParams->rateSet.rate,
4154 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07004155
4156 pAddBssParams->nwType = bssDescription->nwType;
4157
Jeff Johnson32d95a32012-09-10 13:15:23 -07004158 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
4160 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
4161 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304162 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
Jeff Johnson295189b2012-06-20 16:38:30 -07004163
Abhishek Singh525045c2014-12-15 17:18:45 +05304164 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304165 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
4166 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
4167
Abhishek Singh525045c2014-12-15 17:18:45 +05304168 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304169 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
4170 pAddBssParams->cfParamSet.cfpMaxDuration,
4171 pAddBssParams->cfParamSet.cfpDurRemaining,
4172 pAddBssParams->rateSet.numRates);
4173
Abhishek Singh525045c2014-12-15 17:18:45 +05304174 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304175 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
4176 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
4177 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
4178 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 // Use the advertised capabilities from the received beacon/PR
Jeff Johnson32d95a32012-09-10 13:15:23 -07004180 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004182 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05304183 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004184 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004186 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
4187 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07004188
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004190 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 (chanWidthSupp) )
4192 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004193 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
4194 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 }
4196 else
4197 {
4198 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004199 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004201 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
4202 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
4203 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304204
Abhishek Singh525045c2014-12-15 17:18:45 +05304205 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304206 "txChannelWidthSet: %d currentExtChannel: %d "),
4207 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
4208 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
4209
Abhishek Singh525045c2014-12-15 17:18:45 +05304210 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304211 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
4212 pAddBssParams->llnNonGFCoexist,
4213 pAddBssParams->fLsigTXOPProtectionFullSupport,
4214 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 }
4216 }
4217
4218 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05304219 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304220 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004221#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304222 if (psessionEntry->vhtCapability &&
4223 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Jeff Johnsone7245742012-09-05 17:12:55 -07004224 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004225 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
4226 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004227 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
4228 pAddBssParams->currentOperChannel,
4229 pAddBssParams->currentExtChannel,
4230 psessionEntry->apCenterChan,
4231 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004232 }
4233 else
4234 {
4235 pAddBssParams->vhtCapable = 0;
4236 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304237 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304238 "currentExtChannel %d"),pAddBssParams->vhtCapable,
4239 pAddBssParams->vhtTxChannelWidthSet,
4240 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004241#endif
4242
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 // Populate the STA-related parameters here
4244 // Note that the STA here refers to the AP
4245 {
4246 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
4247
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304248 vos_mem_copy(pAddBssParams->staContext.bssId,
4249 bssDescription->bssId,
4250 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
4252
4253 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
4254 pAddBssParams->staContext.uAPSD = 0;
4255 pAddBssParams->staContext.maxSPLen = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004256 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 pAddBssParams->staContext.updateSta = updateEntry;
4258
Abhishek Singh525045c2014-12-15 17:18:45 +05304259 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304260 " shortPreambleSupported: %d"),
4261 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
4262 pAddBssParams->staContext.shortPreambleSupported);
4263
Jeff Johnson32d95a32012-09-10 13:15:23 -07004264 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 {
4266 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
4267 pAddBssParams->staContext.htCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004268 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
4269 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05304270 limLog(pMac, LOG1, FL("StaContext htCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304271 "greenFieldCapable: %d lsigTxopProtection: %d"),
4272 pAddBssParams->staContext.htCapable,
4273 pAddBssParams->staContext.greenFieldCapable,
4274 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004275#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304276 if (psessionEntry->vhtCapability &&
4277 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004278 {
4279 pAddBssParams->staContext.vhtCapable = 1;
4280 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
4281 pBeaconStruct->VHTCaps.muBeamformerCap) &&
4282 psessionEntry->txBFIniFeatureEnabled )
4283 {
4284 pAddBssParams->staContext.vhtTxBFCapable = 1;
4285 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05304286 if (pBeaconStruct->VHTCaps.muBeamformerCap &&
4287 psessionEntry->txMuBformee )
4288 {
4289 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
4290 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
4291 /* Dont allow any other MuBf session as concurrency
4292 * is not supported
4293 */
4294 pMac->isMuBfsessionexist = TRUE;
4295 }
4296
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004297 }
4298#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004299 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 (chanWidthSupp) )
4301 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004302 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004303#ifdef WLAN_FEATURE_11AC
4304 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07004305 {
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004306 pAddBssParams->staContext.vhtTxChannelWidthSet =
4307 pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -07004308 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304309 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304310 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
4311 pAddBssParams->staContext.vhtCapable,
4312 pAddBssParams->staContext.vhtTxChannelWidthSet,
4313 pAddBssParams->staContext.vhtTxBFCapable);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004314#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 }
4316 else
4317 {
4318 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4319 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004320 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
4321 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
4322 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
4323 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
4324 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07004325 /*
4326 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
4327 * if they are set then we will use what ever Beacon coming from AP
4328 * supports. If these values are set as 0 in ini file then
4329 * we will hardcode this values to 0.
4330 */
4331 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4332 (pMac, WNI_CFG_SHORT_GI_20MHZ,
4333 &shortGi20MhzSupport)))
4334 {
4335 if (VOS_TRUE == shortGi20MhzSupport)
4336 {
4337 pAddBssParams->staContext.fShortGI20Mhz =
4338 (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
4339 }
4340 else
4341 {
4342 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
4343 }
4344 }
4345 else
4346 {
4347 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
4348 "CFG,setting value to default"));)
4349 pAddBssParams->staContext.fShortGI20Mhz =
4350 WNI_CFG_SHORT_GI_20MHZ_STADEF;
4351 }
4352
4353 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4354 (pMac, WNI_CFG_SHORT_GI_40MHZ,
4355 &shortGi40MhzSupport)))
4356 {
4357 if (VOS_TRUE == shortGi40MhzSupport)
4358 {
4359 pAddBssParams->staContext.fShortGI40Mhz =
4360 (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
4361 }
4362 else
4363 {
4364 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
4365 }
4366 }
4367 else
4368 {
4369 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
4370 "CFG,setting value to default"));)
4371 pAddBssParams->staContext.fShortGI40Mhz =
4372 WNI_CFG_SHORT_GI_40MHZ_STADEF;
4373 }
4374
Jeff Johnson32d95a32012-09-10 13:15:23 -07004375 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05304376 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08004377 {
4378 pAddBssParams->staContext.htLdpcCapable = 0;
4379 pAddBssParams->staContext.vhtLdpcCapable = 0;
4380 }
4381 else
4382 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05304383 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
4384 pAddBssParams->staContext.htLdpcCapable =
4385 (tANI_U8)pBeaconStruct->HTCaps.advCodingCap;
4386 else
4387 pAddBssParams->staContext.htLdpcCapable = 0;
4388 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
4389 pAddBssParams->staContext.vhtLdpcCapable =
4390 (tANI_U8)pBeaconStruct->VHTCaps.ldpcCodingCap;
4391 else
4392 pAddBssParams->staContext.vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08004393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004394
Jeff Johnson32d95a32012-09-10 13:15:23 -07004395 if( pBeaconStruct->HTInfo.present )
4396 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singh525045c2014-12-15 17:18:45 +05304397 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304398 " delBASupport: %d maxAmsduSize: %d"),
4399 pAddBssParams->staContext.txChannelWidthSet,
4400 pAddBssParams->staContext.mimoPS,
4401 pAddBssParams->staContext.delBASupport,
4402 pAddBssParams->staContext.maxAmsduSize);
4403
Abhishek Singh525045c2014-12-15 17:18:45 +05304404 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304405 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
4406 pAddBssParams->staContext.fDsssCckMode40Mhz,
4407 pAddBssParams->staContext.fShortGI20Mhz);
4408
Abhishek Singh525045c2014-12-15 17:18:45 +05304409 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304410 "htLdpcCapable: %d vhtLdpcCapable: %d"),
4411 pAddBssParams->staContext.fShortGI40Mhz,
4412 pAddBssParams->staContext.maxAmpduSize,
4413 pAddBssParams->staContext.htLdpcCapable,
4414 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 }
4416
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05304417 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
4418 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent || pAddBssParams->staContext.htCapable)) ||
4419 (psessionEntry->limQosEnabled && (pBeaconStruct->edcaPresent || pAddBssParams->staContext.htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 pAddBssParams->staContext.wmmEnabled = 1;
4421 else
4422 pAddBssParams->staContext.wmmEnabled = 0;
4423
4424 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -07004425#ifdef WLAN_FEATURE_11AC
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004426 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004427 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry,
4428 &pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -07004429#else
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004430 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004431 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004432#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,psessionEntry);
4434
4435 }
4436
4437
4438 //Disable BA. It will be set as part of ADDBA negotiation.
4439 for( i = 0; i < STACFG_MAX_TC; i++ )
4440 {
4441 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
4442 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
4443 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
4444 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
4445 }
4446
4447 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4448
4449#if defined WLAN_FEATURE_VOWIFI
4450 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05304451 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304452 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07004453#endif
4454
4455 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4456 pAddBssParams->respReqd = true;
4457
4458 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4459 pAddBssParams->sessionId = psessionEntry->peSessionId;
4460
4461 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4462
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004463 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004464
4465#if defined WLAN_FEATURE_VOWIFI_11R
4466 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05304467 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304468 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004469#endif
4470
Chet Lanctot186b5732013-03-18 10:26:30 -07004471#ifdef WLAN_FEATURE_11W
4472 if (psessionEntry->limRmfEnabled)
4473 {
4474 pAddBssParams->rmfEnabled = 1;
4475 pAddBssParams->staContext.rmfEnabled = 1;
4476 }
4477#endif
4478
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 // Set a new state for MLME
4480
4481 //pMac->lim.gLimMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4482 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4483
Jeff Johnsone7245742012-09-05 17:12:55 -07004484 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004485
Abhishek Singh525045c2014-12-15 17:18:45 +05304486 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304487 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
4488 pAddBssParams->staContext.encryptType,
4489 pAddBssParams->staContext.p2pCapableSta);
4490
Abhishek Singh525045c2014-12-15 17:18:45 +05304491 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304492 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
4493 pAddBssParams->halPersona, psessionEntry->limMlmState);
4494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 //we need to defer the message until we get the response back from HAL.
4496 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4497
4498 msgQ.type = WDA_ADD_BSS_REQ;
4499 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4500 msgQ.reserved = 0;
4501 msgQ.bodyptr = pAddBssParams;
4502 msgQ.bodyval = 0;
4503
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05304504 limLog( pMac, LOG1, FL( "SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
4505 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004506 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004507
4508 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4509 if( eSIR_SUCCESS != retCode)
4510 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004511 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304512 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004513 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 retCode );
4515 goto returnFailure;
4516
4517 }
4518 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07004519 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304520 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 return retCode;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004523
4524 returnFailure:
4525 // Clean-up will be done by the caller...
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304526 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 return retCode;
4528}
4529
4530
4531
4532
4533
Jeff Johnson295189b2012-06-20 16:38:30 -07004534
4535/** -------------------------------------------------------------
4536\fn limPrepareAndSendDelStaCnf
4537\brief deletes DPH entry
4538 changes the MLM mode for station.
4539 calls limSendDelStaCnf
4540\param tpAniSirGlobal pMac
4541\param tpDphHashNode pStaDs
4542\return none
4543 -------------------------------------------------------------*/
4544
4545
4546void
4547limPrepareAndSendDelStaCnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tSirResultCodes statusCode,tpPESession psessionEntry)
4548{
4549 tANI_U16 staDsAssocId = 0;
4550 tSirMacAddr staDsAddr;
4551 tLimMlmStaContext mlmStaContext;
4552
4553 if(pStaDs == NULL)
4554 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004555 PELOGW(limLog(pMac, LOGW, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 return;
4557 }
4558 staDsAssocId = pStaDs->assocId;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304559 vos_mem_copy((tANI_U8 *)staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 pStaDs->staAddr,
4561 sizeof(tSirMacAddr));
4562
4563 mlmStaContext = pStaDs->mlmStaContext;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304564 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4565 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 {
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304567 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 }
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304569 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
4570
4571 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4572 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 {
4574 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304575 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
4576 psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 limSendDelStaCnf(pMac, staDsAddr, staDsAssocId, mlmStaContext, statusCode,psessionEntry);
4579}
4580
4581/** -------------------------------------------------------------
4582\fn limGetStaRateMode
4583\brief Gets the Station Rate Mode.
4584\param tANI_U8 dot11Mode
4585\return none
4586 -------------------------------------------------------------*/
4587tStaRateMode limGetStaRateMode(tANI_U8 dot11Mode)
4588{
4589 switch(dot11Mode)
4590 {
4591 case WNI_CFG_DOT11_MODE_11A:
4592 return eSTA_11a;
4593 case WNI_CFG_DOT11_MODE_11B:
4594 return eSTA_11b;
4595 case WNI_CFG_DOT11_MODE_11G:
4596 return eSTA_11bg;
4597 case WNI_CFG_DOT11_MODE_11N:
4598 return eSTA_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07004599#ifdef WLAN_FEATURE_11AC
4600 case WNI_CFG_DOT11_MODE_11AC:
4601 return eSTA_11ac;
4602#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 case WNI_CFG_DOT11_MODE_ALL:
4604 default:
4605 return eSTA_11n;
4606
4607 }
4608}
4609
4610/** -------------------------------------------------------------
4611\fn limInitPreAuthTimerTable
4612\brief Initialize the Pre Auth Tanle and creates the timer for
4613 each node for the timeout value got from cfg.
4614\param tpAniSirGlobal pMac
4615\param tpLimPreAuthTable pPreAuthTimerTable
4616\return none
4617 -------------------------------------------------------------*/
4618void limInitPreAuthTimerTable(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4619{
4620 tANI_U32 cfgValue;
4621 tANI_U32 authNodeIdx;
4622 tpLimPreAuthNode pAuthNode = pPreAuthTimerTable->pTable;
4623
4624 // Get AUTH_RSP Timers value
4625
4626 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4627 &cfgValue) != eSIR_SUCCESS)
4628 {
4629 /*
4630 ** Could not get AUTH_RSP timeout value
4631 ** from CFG. Log error.
4632 **/
4633 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004634 FL("could not retrieve AUTH_RSP timeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 return;
4636 }
4637
4638 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4639 for(authNodeIdx=0; authNodeIdx<pPreAuthTimerTable->numEntry; authNodeIdx++, pAuthNode++)
4640 {
4641 if (tx_timer_create(&pAuthNode->timer,
4642 "AUTH RESPONSE TIMEOUT",
4643 limAuthResponseTimerHandler,
4644 authNodeIdx,
4645 cfgValue,
4646 0,
4647 TX_NO_ACTIVATE) != TX_SUCCESS)
4648 {
4649 // Cannot create timer. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004650 limLog(pMac, LOGP, FL("Cannot create Auth Rsp timer of Index :%d."), authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 return;
4652 }
4653 pAuthNode->authNodeIdx = (tANI_U8)authNodeIdx;
4654 pAuthNode->fFree = 1;
4655 }
4656
4657}
4658
4659/** -------------------------------------------------------------
4660\fn limAcquireFreePreAuthNode
4661\brief Retrives a free Pre Auth node from Pre Auth Table.
4662\param tpAniSirGlobal pMac
4663\param tpLimPreAuthTable pPreAuthTimerTable
4664\return none
4665 -------------------------------------------------------------*/
4666tLimPreAuthNode * limAcquireFreePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4667{
4668 tANI_U32 i;
4669 tLimPreAuthNode *pTempNode = pPreAuthTimerTable->pTable;
4670 for (i=0; i<pPreAuthTimerTable->numEntry; i++,pTempNode++)
4671 {
4672 if (pTempNode->fFree == 1)
4673 {
4674 pTempNode->fFree = 0;
4675 return pTempNode;
4676 }
4677 }
4678
4679 return NULL;
4680}
4681
4682/** -------------------------------------------------------------
4683\fn limGetPreAuthNodeFromIndex
4684\brief Depending on the Index this retrives the pre auth node.
4685\param tpAniSirGlobal pMac
4686\param tpLimPreAuthTable pAuthTable
4687\param tANI_U32 authNodeIdx
4688\return none
4689 -------------------------------------------------------------*/
4690tLimPreAuthNode * limGetPreAuthNodeFromIndex(tpAniSirGlobal pMac,
4691 tpLimPreAuthTable pAuthTable, tANI_U32 authNodeIdx)
4692{
4693 if ((authNodeIdx >= pAuthTable->numEntry) || (pAuthTable->pTable == NULL))
4694 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004695 limLog(pMac, LOGE, FL("Invalid Auth Timer Index : %d NumEntry : %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 authNodeIdx, pAuthTable->numEntry);
4697 return NULL;
4698 }
4699
4700 return pAuthTable->pTable + authNodeIdx;
4701}
4702
4703/* Util API to check if the channels supported by STA is within range */
4704tSirRetStatus limIsDot11hSupportedChannelsValid(tpAniSirGlobal pMac, tSirAssocReq *assoc)
4705{
4706 /*
4707 * Allow all the stations to join with us.
4708 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4709 * as an input into an algorithm used to select a new channel for the BSS.
4710 * The specification of the algorithm is beyond the scope of this amendment.
4711 */
4712
4713 return (eSIR_SUCCESS);
4714}
4715
4716/* Util API to check if the txpower supported by STA is within range */
4717tSirRetStatus limIsDot11hPowerCapabilitiesInRange(tpAniSirGlobal pMac, tSirAssocReq *assoc,tpPESession psessionEntry)
4718{
4719 tPowerdBm localMaxTxPower;
4720 tANI_U32 localPwrConstraint;
4721
4722 localMaxTxPower = cfgGetRegulatoryMaxTransmitPower(pMac, psessionEntry->currentOperChannel);
4723
4724 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004725 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 return eSIR_FAILURE;
4727 }
4728 localMaxTxPower -= (tPowerdBm)localPwrConstraint;
4729
4730 /**
4731 * The min Tx Power of the associating station should not be greater than (regulatory
4732 * max tx power - local power constraint configured on AP).
4733 */
4734 if(assoc->powerCapability.minTxPower > localMaxTxPower)
4735 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004736 limLog(pMac, LOGW, FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 assoc->powerCapability.minTxPower, localMaxTxPower);
4738 return (eSIR_FAILURE);
4739 }
4740
4741 return (eSIR_SUCCESS);
4742}
4743
4744/** -------------------------------------------------------------
4745\fn limFillRxHighestSupportedRate
4746\brief Fills in the Rx Highest Supported Data Rate field from
4747\ the 'supported MCS set' field in HT capability element.
4748\param tpAniSirGlobal pMac
4749\param tpSirSupportedRates pRates
4750\param tANI_U8* pSupportedMCSSet
4751\return none
4752 -------------------------------------------------------------*/
4753void limFillRxHighestSupportedRate(tpAniSirGlobal pMac, tANI_U16 *rxHighestRate, tANI_U8* pSupportedMCSSet)
4754{
4755 tSirMacRxHighestSupportRate *pRxHighestRate;
4756 tANI_U8 *pBuf;
4757 tANI_U16 rate=0;
4758
4759 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4760 rate = limGetU16(pBuf);
4761
4762 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4763 *rxHighestRate = pRxHighestRate->rate;
4764
4765 return;
4766}
Chet Lanctot186b5732013-03-18 10:26:30 -07004767
4768#ifdef WLAN_FEATURE_11W
4769/** -------------------------------------------------------------
4770\fn limSendSmeUnprotectedMgmtFrameInd
4771\brief Forwards the unprotected management frame to SME.
4772\param tpAniSirGlobal pMac
4773\param frameType - 802.11 frame type
4774\param frame - frame buffer
4775\param sessionId - id for the current session
4776\param psessionEntry - PE session context
4777\return none
4778 -------------------------------------------------------------*/
4779void limSendSmeUnprotectedMgmtFrameInd(
4780 tpAniSirGlobal pMac, tANI_U8 frameType,
4781 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
4782 tpPESession psessionEntry)
4783{
4784 tSirMsgQ mmhMsg;
4785 tSirSmeUnprotMgmtFrameInd * pSirSmeMgmtFrame = NULL;
4786 tANI_U16 length;
4787
4788 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4789
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304790 pSirSmeMgmtFrame = vos_mem_malloc(length);
4791 if (NULL == pSirSmeMgmtFrame)
Chet Lanctot186b5732013-03-18 10:26:30 -07004792 {
4793 limLog(pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304794 FL("AllocateMemory failed for tSirSmeUnprotectedMgmtFrameInd"));
Chet Lanctot186b5732013-03-18 10:26:30 -07004795 return;
4796 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304797 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Chet Lanctot186b5732013-03-18 10:26:30 -07004798
4799 pSirSmeMgmtFrame->sessionId = sessionId;
4800 pSirSmeMgmtFrame->frameType = frameType;
4801
4802 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
4803 pSirSmeMgmtFrame->frameLen = frameLen;
4804
4805 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4806 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4807 mmhMsg.bodyval = 0;
4808
4809 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4810 return;
4811}
4812#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004813
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004814#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004815/** -------------------------------------------------------------
4816\fn limSendSmeTsmIEInd
4817\brief Forwards the TSM IE information to SME.
4818\param tpAniSirGlobal pMac
4819\param psessionEntry - PE session context
4820\param tid - traffic id
4821\param state - tsm state (enabled/disabled)
4822\param measurementInterval - measurement interval
4823\return none
4824 -------------------------------------------------------------*/
4825void limSendSmeTsmIEInd(tpAniSirGlobal pMac, tpPESession psessionEntry,
4826 tANI_U8 tid, tANI_U8 state, tANI_U16 measInterval)
4827{
4828 tSirMsgQ mmhMsg;
4829 tpSirSmeTsmIEInd pSirSmeTsmIeInd = NULL;
4830
4831 if (!pMac || !psessionEntry)
4832 {
4833 return;
4834 }
4835 pSirSmeTsmIeInd = vos_mem_malloc(sizeof(tSirSmeTsmIEInd));
4836 if (NULL == pSirSmeTsmIeInd)
4837 {
4838 limLog(pMac, LOGP,
4839 FL("AllocateMemory failed for tSirSmeTsmIEInd"));
4840 return;
4841 }
4842 vos_mem_set((void*)pSirSmeTsmIeInd, sizeof(tSirSmeTsmIEInd), 0);
4843
4844 pSirSmeTsmIeInd->sessionId = psessionEntry->smeSessionId;
4845 pSirSmeTsmIeInd->tsmIe.tsid = tid;
4846 pSirSmeTsmIeInd->tsmIe.state= state;
4847 pSirSmeTsmIeInd->tsmIe.msmt_interval= measInterval;
4848
4849 mmhMsg.type = eWNI_SME_TSM_IE_IND;
4850 mmhMsg.bodyptr = pSirSmeTsmIeInd;
4851 mmhMsg.bodyval = 0;
4852
4853 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4854 return;
4855}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004856#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004857
4858