blob: c20c7a6f1ea747fccfbc728475e7f48d9b6a598e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limAssocUtils.cc contains the utility functions
30 * LIM uses while processing (Re) Association messages.
31 * Author: Chandra Modumudi
32 * Date: 02/13/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 * 05/26/10 js WPA handling in (Re)Assoc frames
37 *
38 */
39
40#include "palTypes.h"
41#include "aniGlobal.h"
42#include "wniApi.h"
43#include "sirCommon.h"
44
Satyanarayana Dash6f438272015-03-03 18:01:06 +053045#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070046#include "pmmApi.h"
47#include "cfgApi.h"
48
49#include "schApi.h"
50#include "utilsApi.h"
51#include "limUtils.h"
52#include "limAssocUtils.h"
53#include "limSecurityUtils.h"
54#include "limSerDesUtils.h"
55#include "limStaHashApi.h"
56#include "limAdmitControl.h"
57#include "limSendMessages.h"
58#include "limIbssPeerMgmt.h"
59#include "limSession.h"
60
61#include "vos_types.h"
62#include "wlan_qct_wda.h"
63
64/*
65 * fill up the rate info properly based on what is actually supported by the peer
66 * TBD TBD TBD
67 */
68void
69limFillSupportedRatesInfo(
70 tpAniSirGlobal pMac,
71 tpDphHashNode pSta,
72 tpSirSupportedRates pRates,
73 tpPESession psessionEntry)
74{
75 //pSta will be NULL for self entry, so get the opRateMode based on the self mode.
76 //For the peer entry get it from the peer Capabilities present in hash table
77 if(pSta == NULL)
78 pRates->opRateMode = limGetStaRateMode((tANI_U8)psessionEntry->dot11mode);
79 else
80 pRates->opRateMode = limGetStaPeerType(pMac, pSta, psessionEntry);
81
82}
83
84
85/**
86 * limCmpSSid()
87 *
88 *FUNCTION:
89 * This function is called in various places within LIM code
90 * to determine whether received SSid is same as SSID in use.
91 *
92 *LOGIC:
93 *
94 *ASSUMPTIONS:
95 * NA
96 *
97 *NOTE:
98 * NA
99 *
100 * @param *prxSSid - pointer to SSID structure
101 *
102 * @return status - true for SSID match else false.
103 */
104
105tANI_U8
106limCmpSSid(tpAniSirGlobal pMac, tSirMacSSid *prxSSid,tpPESession psessionEntry)
107{
108
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530109 if (vos_mem_compare((tANI_U8* ) prxSSid, (tANI_U8 *) &psessionEntry->ssId,
110 (tANI_U8) (psessionEntry->ssId.length + 1)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700111 return true;
112 else
113 return false;
114
115} /****** end limCmpSSid() ******/
116
117
118
119/**
120 * limCompareCapabilities()
121 *
122 *FUNCTION:
123 * This function is called during Association/Reassociation
124 * frame handling to determine whether received capabilities
125 * match with local capabilities or not.
126 *
127 *LOGIC:
128 *
129 *ASSUMPTIONS:
130 * NA
131 *
132 *NOTE:
133 * NA
134 *
135 * @param pMac - Pointer to Global MAC structure
136 * @param pAssocReq - Pointer to received Assoc Req frame
137 * @param pLocalCapabs - Pointer to local capabilities
138 *
139 * @return status - true for Capabilitity match else false.
140 */
141
142tANI_U8
143limCompareCapabilities(tpAniSirGlobal pMac,
144 tSirAssocReq *pAssocReq,
145 tSirMacCapabilityInfo *pLocalCapabs,tpPESession psessionEntry)
146{
147 tANI_U32 val;
148
149
150 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||
151 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
152 (pAssocReq->capabilityInfo.ibss) )
153 {
154 // Requesting STA asserting IBSS capability.
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530155 limLog(pMac, LOG1,FL("Requesting STA asserting IBSS capability"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 return false;
157 }
158
159 // Compare CF capabilities
160 if (pAssocReq->capabilityInfo.cfPollable ||
161 pAssocReq->capabilityInfo.cfPollReq)
162 {
163 // AP does not support PCF functionality
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530164 limLog(pMac, LOG1,FL(" AP does not support PCF functionality"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 return false;
166 }
167
168#if 0 //See CR24696 for analysis
169 // Compare privacy capability
170 if (pAssocReq->capabilityInfo.privacy != pLocalCapabs->privacy)
171 {
172 // AP does not support privacy
173 return false;
174 }
175#endif
176
177 // Compare short preamble capability
178 if (pAssocReq->capabilityInfo.shortPreamble &&
179 (pAssocReq->capabilityInfo.shortPreamble !=
180 pLocalCapabs->shortPreamble))
181 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530182
183 // Allowing a STA requesting short preamble while
184 // AP does not support it
Jeff Johnson295189b2012-06-20 16:38:30 -0700185#if 0
186 // AP does not support short preamable
187 return false;
188#endif
189 }
190
191
Nirav Shahbc35fb72013-12-12 18:14:06 +0530192 limLog(pMac, LOG1, "QoS in AssocReq: %d, local capabs qos: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700193 pAssocReq->capabilityInfo.qos,
194 pLocalCapabs->qos);
195
196 // Compare QoS capability
197 if (pAssocReq->capabilityInfo.qos &&
198 (pAssocReq->capabilityInfo.qos != pLocalCapabs->qos))
199 {
200 /*Temporary hack for UPF to skip 11e capability check in order to interop with
201 CSR - proper fix needs to be put in place*/
202 if ( 0 != vos_get_skip_11e_check())
203 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530204 limLog(pMac, LOG1, FL("Received unmatched QOS but cfg to suppress"
205 " - continuing"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 }
207 else
208 {
209 // AP does not support QoS capability
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530210 limLog(pMac, LOG1,FL("AP does not support QoS capability"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 return false;
212 }
213 }
214
215
216 /*
217 * If AP supports shortSlot and if apple user has
218 * enforced association only from shortSlot station,
219 * then AP must reject any station that does not support
220 * shortSlot
221 */
222 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && (pLocalCapabs->shortSlotTime == 1) )
223
224 {
225 if (wlan_cfgGetInt(pMac, WNI_CFG_ACCEPT_SHORT_SLOT_ASSOC_ONLY, &val) != eSIR_SUCCESS)
226 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700227 limLog(pMac, LOGP, FL("error getting WNI_CFG_FORCE_SHORT_SLOT_ASSOC_ONLY "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 return false;
229 }
230 if(val)
231 {
232 if (pAssocReq->capabilityInfo.shortSlotTime != pLocalCapabs->shortSlotTime)
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530233 {
234 limLog(pMac, LOG1,FL("Received shortSlotTime %d does not "
235 "match with local %d"),pAssocReq->capabilityInfo.shortSlotTime,
236 pLocalCapabs->shortSlotTime);
237 return false;
238 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 }
240 }
241
242 return true;
243} /****** end limCompareCapabilities() ******/
244
245
246/**
247 * limCheckRxBasicRates()
248 *
249 *FUNCTION:
250 * This function is called during Association/Reassociation
251 * frame handling to determine whether received rates in
252 * Assoc/Reassoc request frames include all BSS basic rates
253 * or not.
254 *
255 *LOGIC:
256 *
257 *ASSUMPTIONS:
258 * NA
259 *
260 *NOTE:
261 * NA
262 *
263 * @param rxRateSet - pointer to SSID structure
264 *
265 * @return status - true if ALL BSS basic rates are present in the
266 * received rateset else false.
267 */
268
269tANI_U8
270limCheckRxBasicRates(tpAniSirGlobal pMac, tSirMacRateSet rxRateSet,tpPESession psessionEntry)
271{
272 tSirMacRateSet *pRateSet, basicRate;
273 tANI_U8 i, j, k, match;
274
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530275 pRateSet = vos_mem_malloc(sizeof(tSirMacRateSet));
276 if (NULL == pRateSet)
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530278 limLog(pMac, LOGP, FL("call to AllocateMemory failed for RATESET"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280 return false;
281 }
282
283
284 #if 0
285 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
286 (tANI_U8 *) &pRateSet->rate,
287 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
288 {
289 /// Could not get Operational rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700290 limLog(pMac, LOGP, FL("could not retrieve Operational rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700291
292 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530293 vos_mem_free((tANI_U8 *) pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
295 return false;
296 }
297 #endif //TO SUPPORT BT-AMP
298
299 /* Copy operational rate set from session Entry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530300 vos_mem_copy(pRateSet->rate, (psessionEntry->rateSet.rate),
301 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302
303 pRateSet->numRates = psessionEntry->rateSet.numRates;
304
305 // Extract BSS basic rateset from operational rateset
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -0700306 for (i = 0, j = 0; ((i < pRateSet->numRates) && (i < SIR_MAC_RATESET_EID_MAX)) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 {
308 if ((pRateSet->rate[i] & 0x80) == 0x80)
309 {
310 // msb is set, so this is a basic rate
311 basicRate.rate[j++] = pRateSet->rate[i];
312 }
313 }
314
315 /*
316 * For each BSS basic rate, find if it is present in the
317 * received rateset.
318 */
319 for (k = 0; k < j; k++)
320 {
321 match = 0;
Krunal Sonia75019a2013-05-01 01:08:22 -0700322 for (i = 0; ((i < rxRateSet.numRates) && (i < SIR_MAC_RATESET_EID_MAX)); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 {
324 if ((rxRateSet.rate[i] | 0x80) == basicRate.rate[k])
325 match = 1;
326 }
327
328 if (!match)
329 {
330 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530331 vos_mem_free((tANI_U8 *)pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700332
333 return false;
334 }
335 }
336
337 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530338 vos_mem_free((tANI_U8 *)pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700339
340 return true;
341} /****** end limCheckRxBasicRates() ******/
342
343
344
345/**
346 * limCheckMCSSet()
347 *
348 *FUNCTION:
349 * This function is called during Association/Reassociation
350 * frame handling to determine whether received MCS rates in
351 * Assoc/Reassoc request frames includes all Basic MCS Rate Set or not.
352 *
353 *LOGIC:
354 *
355 *ASSUMPTIONS:
356 * NA
357 *
358 *NOTE:
359 * NA
360 *
361 * @param supportedMCSSet - pointer to Supported MCS Rate Set
362 *
363 * @return status - true if ALL MCS Basic Rate Set rates are present in the
364 * received rateset else false.
365 */
366
367tANI_U8
368limCheckMCSSet(tpAniSirGlobal pMac, tANI_U8* supportedMCSSet)
369{
370 tANI_U8 basicMCSSet[SIZE_OF_BASIC_MCS_SET] = {0};
371 tANI_U32 cfgLen = 0;
372 tANI_U8 i;
373 tANI_U8 validBytes;
374 tANI_U8 lastByteMCSMask = 0x1f;
375
376
377 cfgLen = WNI_CFG_BASIC_MCS_SET_LEN;
378 if (wlan_cfgGetStr(pMac, WNI_CFG_BASIC_MCS_SET,
379 (tANI_U8 *) basicMCSSet,
380 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
381 {
382 /// Could not get Basic MCS rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700383 limLog(pMac, LOGP, FL("could not retrieve Basic MCS rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 return false;
385 }
386
387 validBytes = VALID_MCS_SIZE/8;
388
389 //check if all the Basic MCS Bits are set in supported MCS bitmap
390 for(i=0; i<validBytes; i++)
391 {
392 if( (basicMCSSet[i] & supportedMCSSet[i]) != basicMCSSet[i])
393 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530394 //Log is avaiable in calling function in file limProcessAssocReqFrame.c
395 limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is"
396 "not supported by the Station."));
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 return false;
398 }
399 }
400
401 //check the last 5 bits of the valid MCS bitmap
402 if( ((basicMCSSet[i] & lastByteMCSMask) & (supportedMCSSet[i] & lastByteMCSMask)) !=
403 (basicMCSSet[i] & lastByteMCSMask))
404 {
Nirav Shahbc35fb72013-12-12 18:14:06 +0530405 //Log is avaiable in calling function in file limProcessAssocReqFrame.c
406 limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is not"
407 "supported by the Station."));
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 return false;
409 }
410
411 return true;
412}
413
Jeff Johnson295189b2012-06-20 16:38:30 -0700414
415#define SECURITY_SUITE_TYPE_MASK 0xFF
416#define SECURITY_SUITE_TYPE_WEP40 0x1
417#define SECURITY_SUITE_TYPE_TKIP 0x2
418#define SECURITY_SUITE_TYPE_CCMP 0x4
419#define SECURITY_SUITE_TYPE_WEP104 0x4
420
421/**
422 * limCheckRxRSNIeMatch()
423 *
424 *FUNCTION:
425 * This function is called during Association/Reassociation
426 * frame handling to determine whether received RSN in
427 * Assoc/Reassoc request frames include supported cipher suites or not.
428 *
429 *LOGIC:
430 *
431 *ASSUMPTIONS:
432 * NA
433 *
434 *NOTE:
435 * NA
436 *
437 * @param rxRSNIe - received RSN IE in (Re)Assco req
438 *
439 * @return status - true if ALL BSS basic rates are present in the
440 * received rateset else false.
441 */
442
443tANI_U8
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700444limCheckRxRSNIeMatch(tpAniSirGlobal pMac, tDot11fIERSN rxRSNIe,tpPESession pSessionEntry,
445 tANI_U8 staIsHT, tANI_BOOLEAN *pmfConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -0700446{
447 tDot11fIERSN *pRSNIe;
448 tANI_U8 i, j, match, onlyNonHtCipher = 1;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700449#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700450 tANI_BOOLEAN weArePMFCapable;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800451 tANI_BOOLEAN weRequirePMF;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700452 tANI_BOOLEAN theyArePMFCapable;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800453 tANI_BOOLEAN theyRequirePMF;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700455
456
457 //RSN IE should be received from PE
458 pRSNIe = &pSessionEntry->gStartBssRSNIe;
459
460 // Check groupwise cipher suite
461 for (i = 0; i < sizeof(rxRSNIe.gp_cipher_suite); i++)
462 {
463 if (pRSNIe->gp_cipher_suite[i] != rxRSNIe.gp_cipher_suite[i])
464 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530465 limLog(pMac, LOG1, FL("RSN group cipher suite does not match local"
466 " %d recieved %d"),pRSNIe->gp_cipher_suite[i],
467 rxRSNIe.gp_cipher_suite[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
469 }
470 }
471
472 /*
473 * For each Pairwise cipher suite check whether we support
474 * received pairwise
475 */
476 match = 0;
477 for (i = 0; i < rxRSNIe.pwise_cipher_suite_count; i++)
478 {
479 for(j = 0; j < pRSNIe->pwise_cipher_suite_count; j++)
480 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530481 if (vos_mem_compare(&rxRSNIe.pwise_cipher_suites[i],
482 &pRSNIe->pwise_cipher_suites[j],
483 sizeof(pRSNIe->pwise_cipher_suites[j])))
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 {
485 match = 1;
486 break;
487 }
488 }
489
490 if ((staIsHT)
491#ifdef ANI_LITTLE_BYTE_ENDIAN
492 &&( (rxRSNIe.pwise_cipher_suites[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
493#else
494 &&( (rxRSNIe.pwise_cipher_suites[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
495#endif
496 {
497 onlyNonHtCipher=0;
498 }
499
500 }
501
502 if ((!match) || ((staIsHT) && onlyNonHtCipher))
503 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530504 limLog(pMac, LOG1, FL("pairwise cipher suite does not match(%d)"
505 "staIsHT %d onlyNonHtCipher %d"),match,staIsHT,
506 onlyNonHtCipher);
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 return eSIR_MAC_INVALID_PAIRWISE_CIPHER_STATUS;
508 }
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -0800509 /* Check RSN capabilities
510 * Bit 0 of First Byte - PreAuthentication Capability
511 */
512 if(((rxRSNIe.RSN_Cap[0] >> 0) & 0x1) == true) //this is supported by AP only
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530514 limLog(pMac, LOG1, FL("Preuthentication Capability is set"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 return eSIR_MAC_INVALID_RSN_IE_CAPABILITIES_STATUS;
516 }
517
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700518 *pmfConnection = eANI_BOOLEAN_FALSE;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800519
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700520#ifdef WLAN_FEATURE_11W
Chet Lanctot8cecea22014-02-11 19:09:36 -0800521 weArePMFCapable = pSessionEntry->pLimStartBssReq->pmfCapable;
522 weRequirePMF = pSessionEntry->pLimStartBssReq->pmfRequired;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700523 theyArePMFCapable = (rxRSNIe.RSN_Cap[0] >> 7) & 0x1;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800524 theyRequirePMF = (rxRSNIe.RSN_Cap[0] >> 6) & 0x1;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700525
Chet Lanctotec4de332013-10-11 15:42:22 -0700526 if ((theyRequirePMF && theyArePMFCapable && !weArePMFCapable) ||
527 (weRequirePMF && !theyArePMFCapable))
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700528 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530529 limLog(pMac, LOG1, FL("Association fail, robust management frames "
530 "policy violation theyRequirePMF =%d theyArePMFCapable %d "
531 "weArePMFCapable %d weRequirePMF %d theyArePMFCapable %d"),
532 theyRequirePMF,theyArePMFCapable,weArePMFCapable,weRequirePMF,
533 theyArePMFCapable);
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700534 return eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION;
535 }
536
537 if(theyArePMFCapable && weArePMFCapable)
538 *pmfConnection = eANI_BOOLEAN_TRUE;
Chet Lanctot8cecea22014-02-11 19:09:36 -0800539
540 limLog(pMac, LOG1, FL("weAreCapable %d, weRequire %d, theyAreCapable %d, "
541 "theyRequire %d, PMFconnection %d"),
542 weArePMFCapable, weRequirePMF, theyArePMFCapable, theyRequirePMF, *pmfConnection);
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700543#endif
544
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return eSIR_SUCCESS;
546} /****** end limCheckRxRSNIeMatch() ******/
547
548/**
549 * limCheckRxWPAIeMatch()
550 *
551 *FUNCTION:
552 * This function is called during Association/Reassociation
553 * frame handling to determine whether received RSN in
554 * Assoc/Reassoc request frames include supported cipher suites or not.
555 *
556 *LOGIC:
557 *
558 *ASSUMPTIONS:
559 * NA
560 *
561 *NOTE:
562 * NA
563 *
564 * @param rxWPAIe - Received WPA IE in (Re)Assco req
565 *
566 * @return status - true if ALL BSS basic rates are present in the
567 * received rateset else false.
568 */
569
570tANI_U8
571limCheckRxWPAIeMatch(tpAniSirGlobal pMac, tDot11fIEWPA rxWPAIe,tpPESession pSessionEntry, tANI_U8 staIsHT)
572{
573 tDot11fIEWPA *pWPAIe;
574 tANI_U8 i, j, match, onlyNonHtCipher = 1;
575
576 // WPA IE should be received from PE
577 pWPAIe = &pSessionEntry->gStartBssWPAIe;
578
579 // Check groupwise cipher suite
580 for (i = 0; i < 4; i++)
581 {
582 if (pWPAIe->multicast_cipher[i] != rxWPAIe.multicast_cipher[i])
583 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530584 limLog(pMac, LOG1, FL("WPA group cipher suite does not match local"
585 " %d recieved %d"),pWPAIe->multicast_cipher[i],
586 rxWPAIe.multicast_cipher[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
588 }
589 }
590
591 /*
592 * For each Pairwise cipher suite check whether we support
593 * received pairwise
594 */
595 match = 0;
596 for (i = 0; i < rxWPAIe.unicast_cipher_count; i++)
597 {
598 for(j = 0; j < pWPAIe->unicast_cipher_count; j++)
599 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530600 if (vos_mem_compare(rxWPAIe.unicast_ciphers[i],
601 pWPAIe->unicast_ciphers[j],
602 4))
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 {
604 match = 1;
605 break;
606 }
607 }
608
609 if ((staIsHT)
610#ifdef ANI_LITTLE_BYTE_ENDIAN
611 &&( (rxWPAIe.unicast_ciphers[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
612#else
613 &&( (rxWPAIe.unicast_ciphers[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
614#endif
615 {
616 onlyNonHtCipher=0;
617 }
618
619 }
620
621 if ((!match) || ((staIsHT) && onlyNonHtCipher))
622 {
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530623 limLog(pMac, LOG1, FL("pairwise cipher suite does not match(%d)"
624 "staIsHT %d onlyNonHtCipher %d"),match,staIsHT,
625 onlyNonHtCipher);
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 return eSIR_MAC_CIPHER_SUITE_REJECTED_STATUS;
627 }
628
629 return eSIR_SUCCESS;
630} /****** end limCheckRxWPAIeMatch() ******/
631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632
633/**
634 * limCleanupRxPath()
635 *
636 *FUNCTION:
637 * This function is called to cleanup STA state at SP & RFP.
638 *
639 *LOGIC:
640 * To circumvent RFP's handling of dummy packet when it does not
641 * have an incomplete packet for the STA to be deleted, a packet
642 * with 'more framgents' bit set will be queued to RFP's WQ before
643 * queuing 'dummy packet'.
644 * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
645 * (Disassociation frame) and routing flags in BD set to eCPU's
646 * Low Priority WQ.
647 * RFP cleans up its local context for the STA id mentioned in the
648 * BD and then pushes BD to eCPU's low priority WQ.
649 *
650 *ASSUMPTIONS:
651 * NA
652 *
653 *NOTE:
654 * NA
655 *
656 * @param pMac Pointer to Global MAC structure
657 * @param pStaDs Pointer to the per STA data structure
658 * initialized by LIM and maintained at DPH
659 *
660 * @return None
661 */
662
663tSirRetStatus
664limCleanupRxPath(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry)
665{
666 tSirRetStatus retCode = eSIR_SUCCESS;
667
668
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530669 limLog( pMac, LOG1, FL("Cleanup Rx Path for AID : %d"
670 "psessionEntry->limSmeState : %d, mlmState : %d"),
671 pStaDs->assocId, psessionEntry->limSmeState,
672 pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 limAbortBackgroundScan( pMac );
Agarwal Ashish87039eb2014-01-15 14:13:15 +0530675 psessionEntry->isCiscoVendorAP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 if (pMac->lim.gLimAddtsSent)
677 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700678 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
680 }
681
682 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
683 {
684 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER,
685 pStaDs->assocId);
686
687 if (!pStaDs->mlmStaContext.updateContext)
688 {
689 /**
690 * There is no context at Polaris to delete.
691 * Release our assigned AID back to the free pool
692 */
kaliu24cedc42016-03-25 11:12:12 +0800693 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
kaliu24cedc42016-03-25 11:12:12 +0800695 {
696 limDelSta(pMac, pStaDs, false, psessionEntry);
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800697 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 }
699 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 return retCode;
701 }
702 }
703
704 //delete all tspecs associated with this sta.
705 limAdmitControlDeleteSta(pMac, pStaDs->assocId);
706
Jeff Johnson295189b2012-06-20 16:38:30 -0700707
708 /**
709 * Make STA hash entry invalid at eCPU so that DPH
710 * does not process any more data packets and
711 * releases those BDs
712 */
713 pStaDs->valid = 0;
714 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
715
716 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
717 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700718 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 /* Deactivating probe after heart beat timer */
721 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
Leela Venkata Kiran Kumar Reddy Chiralade5d0592013-09-20 17:09:35 -0700722 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
724 limDeactivateAndChangeTimer(pMac, eLIM_KEEPALIVE_TIMER);
725 pMac->lim.gLastBeaconDtimCount = 0;
726 pMac->lim.gLastBeaconDtimPeriod = 0;
727
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800728#ifdef FEATURE_WLAN_ESE
729#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700730 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
731#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800733#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -0700734#endif
735
736 /**
737 * Update the status for PMM module
738 */
739 pmmResetPmmState(pMac);
740 }
741#ifdef WLAN_DEBUG
742 // increment a debug count
743 pMac->lim.gLimNumRxCleanup++;
744#endif
745
Abhishek Singhde7f0512015-10-23 14:31:15 +0530746 /* Do DEL BSS or DEL STA only if ADD BSS was success */
747 if (!psessionEntry->addBssfailed)
748 {
749 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE)
750 retCode = limDelBss( pMac, pStaDs,
751 psessionEntry->bssIdx, psessionEntry);
752 else
753 retCode = limDelSta( pMac, pStaDs, true, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 return retCode;
756
757} /*** end limCleanupRxPath() ***/
758
759
760/**
761 * limSendDelStaCnf()
762 *
763 *FUNCTION:
764 * This function is called to send appropriate CNF message to SME
765 *
766 *LOGIC:
767 *
768 *
769 *ASSUMPTIONS:
770 * NA
771 *
772 *NOTE:
773 * NA
774 *
775 * @param pMac Pointer to Global MAC structure
776 * @param tpAniSirGlobal pMac,
777 * @param tSirMacAddr staDsAddr,
778 * @param tANI_U16 staDsAssocId,
779 * @param tLimMlmStaContext mlmStaContext,
780 * @param tSirResultCodes statusCode
781 *
782 * @return None
783 */
784
785void
786limSendDelStaCnf(tpAniSirGlobal pMac, tSirMacAddr staDsAddr,
787 tANI_U16 staDsAssocId, tLimMlmStaContext mlmStaContext, tSirResultCodes statusCode,tpPESession psessionEntry)
788{
789
790 tLimMlmDisassocCnf mlmDisassocCnf;
791 tLimMlmDeauthCnf mlmDeauthCnf;
792 tLimMlmPurgeStaInd mlmPurgeStaInd;
793
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530794 limLog(pMac, LOG1, FL("Sessionid: %d staDsAssocId: %d Trigger: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530795 "statusCode: %d staDsAddr: "MAC_ADDRESS_STR),psessionEntry->peSessionId,
796 staDsAssocId, mlmStaContext.cleanupTrigger, statusCode,
797 MAC_ADDR_ARRAY(staDsAddr));
798
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
800 {
801 // Set BSSID at CFG to null
802 tSirMacAddr nullAddr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
803 #if 0
804 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) &nullAddr,
805 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
806 {
807 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700808 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700809
810 return;
811 }
812 #endif//TO SUPPORT BT-AMP
813
814 sirCopyMacAddr(nullAddr,psessionEntry->bssId);
815
816 // Free up buffer allocated for JoinReq held by
817 // MLM state machine
818 if (psessionEntry->pLimMlmJoinReq)
819 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530820 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 psessionEntry->pLimMlmJoinReq = NULL;
822 }
823
824 psessionEntry->limAID = 0;
825
Jeff Johnson295189b2012-06-20 16:38:30 -0700826 }
827
828 if ((mlmStaContext.cleanupTrigger ==
829 eLIM_HOST_DISASSOC) ||
830 (mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530831 eLIM_PROMISCUOUS_MODE_DISASSOC) ||
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 (mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530833 eLIM_LINK_MONITORING_DISASSOC))
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 {
835 /**
836 * Host or LMM driven Disassociation.
837 * Issue Disassoc Confirm to SME.
838 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530839 limLog( pMac, LOGW, FL("Lim Posting DISASSOC_CNF to Sme.Trigger: %d"),
840 mlmStaContext.cleanupTrigger);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841
842
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530843 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
844 (tANI_U8 *) staDsAddr,
845 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 mlmDisassocCnf.resultCode = statusCode;
Wu Gao742b7352015-10-16 19:10:40 +0800847 mlmDisassocCnf.aid = staDsAssocId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 mlmDisassocCnf.disassocTrigger =
849 mlmStaContext.cleanupTrigger;
850 /* Update PE session Id*/
851 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
852
853 limPostSmeMessage(pMac,
854 LIM_MLM_DISASSOC_CNF,
855 (tANI_U32 *) &mlmDisassocCnf);
856 }
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +0530857 else if ((mlmStaContext.cleanupTrigger == eLIM_HOST_DEAUTH) ||
858 (mlmStaContext.cleanupTrigger == eLIM_LINK_MONITORING_DEAUTH))
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 {
860 /**
861 * Host or LMM driven Deauthentication.
862 * Issue Deauth Confirm to SME.
863 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530864 limLog( pMac, LOGW, FL("Lim Posting DEAUTH_CNF to Sme.Trigger: %d"),
865 mlmStaContext.cleanupTrigger);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530866 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
867 (tANI_U8 *) staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 sizeof(tSirMacAddr));
869 mlmDeauthCnf.resultCode = statusCode;
Wu Gao742b7352015-10-16 19:10:40 +0800870 mlmDeauthCnf.aid = staDsAssocId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 mlmDeauthCnf.deauthTrigger =
872 mlmStaContext.cleanupTrigger;
873 /* PE session Id */
874 mlmDeauthCnf.sessionId = psessionEntry->peSessionId;
875
876 limPostSmeMessage(pMac,
877 LIM_MLM_DEAUTH_CNF,
878 (tANI_U32 *) &mlmDeauthCnf);
879 }
880 else if ((mlmStaContext.cleanupTrigger ==
881 eLIM_PEER_ENTITY_DISASSOC) ||
882 (mlmStaContext.cleanupTrigger ==
883 eLIM_PEER_ENTITY_DEAUTH))
884 {
885 /**
886 * Received Disassociation/Deauthentication from peer.
887 * Issue Purge Ind to SME.
888 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530889 limLog( pMac, LOGW, FL("Lim Posting PURGE_STA_IND to Sme.Trigger: %d"),
890 mlmStaContext.cleanupTrigger) ;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530891 vos_mem_copy((tANI_U8 *) &mlmPurgeStaInd.peerMacAddr,
892 (tANI_U8 *) staDsAddr,
893 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 mlmPurgeStaInd.reasonCode = (tANI_U8) mlmStaContext.disassocReason;
895 mlmPurgeStaInd.aid = staDsAssocId;
896 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
897 mlmPurgeStaInd.sessionId = psessionEntry->peSessionId;
898
899 limPostSmeMessage(pMac,
900 LIM_MLM_PURGE_STA_IND,
901 (tANI_U32 *) &mlmPurgeStaInd);
902 }
903 else if(mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE)
904 {
905 //PE setup the peer entry in HW upfront, right after join is completed.
906 //If there is a failure during rest of the assoc sequence, this context needs to be cleaned up.
907 tANI_U8 smesessionId;
908 tANI_U16 smetransactionId;
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530909 tLimSmeStates tempLimSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700910
911 smesessionId = psessionEntry->smeSessionId;
912 smetransactionId = psessionEntry->transactionId;
913
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530914 tempLimSmeState = psessionEntry->limSmeState;
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700916 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700917
Jeff Johnsone7245742012-09-05 17:12:55 -0700918 //if it is a reassoc failure to join new AP
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530919 //eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA result code is used
920 //during assoc and reassoc, so sme state req to distinguish them
Madan Mohan Koyyalamudif33324b2012-11-06 19:16:17 -0800921 if((mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE) ||
Santhosh Kumar Padmaa2291d72014-05-23 18:08:50 +0530922 (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +0530923 (mlmStaContext.resultCode == eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE) ||
924 (mlmStaContext.resultCode == eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA
925 && tempLimSmeState == eLIM_SME_WT_REASSOC_STATE)
926 )
Jeff Johnsone7245742012-09-05 17:12:55 -0700927 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530928 limLog( pMac, LOG1, FL("Lim Posting eWNI_SME_REASSOC_RSP to SME"
929 "resultCode: %d, statusCode: %d,"
930 "sessionId: %d"),
931 mlmStaContext.resultCode,
932 mlmStaContext.protStatusCode,
933 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -0700934 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS )
935 {
936 peDeleteSession(pMac, psessionEntry);
937 psessionEntry = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530938 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700939 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
940 mlmStaContext.resultCode, mlmStaContext.protStatusCode, psessionEntry,
941 smesessionId, smetransactionId);
942 }
943 else
944 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530945 vos_mem_free(psessionEntry->pLimJoinReq);
946 psessionEntry->pLimJoinReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700947
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530948 limLog( pMac, LOG1, FL("Lim Posting eWNI_SME_JOIN_RSP to SME."
949 "resultCode: %d,statusCode: %d,"
950 "sessionId: %d"),
951 mlmStaContext.resultCode,
952 mlmStaContext.protStatusCode,
953 psessionEntry->peSessionId);
954 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS)
955 {
956 peDeleteSession(pMac,psessionEntry);
957 psessionEntry = NULL;
958 }
959
960 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, mlmStaContext.resultCode, mlmStaContext.protStatusCode,
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 psessionEntry, smesessionId, smetransactionId);
Jeff Johnsone7245742012-09-05 17:12:55 -0700962 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700963
964 }
965
966 if((NULL != psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 && (eLIM_AP_ROLE != psessionEntry->limSystemRole )
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 )
969 {
970 peDeleteSession(pMac,psessionEntry);
971 psessionEntry = NULL;
972 }
973}
974
975/**
976 * limRejectAssociation()
977 *
978 *FUNCTION:
979 * This function is called whenever Re/Association Request need
980 * to be rejected due to failure in assigning an AID or failure
981 * in adding STA context at Polaris or reject by applications.
982 *
983 *LOGIC:
984 * Resources allocated if any are freedup and (Re) Association
985 * Response frame is sent to requesting STA. Pre-Auth context
986 * will be added for this STA if it does not exist already
987 *
988 *ASSUMPTIONS:
989 *
990 *NOTE:
991 *
992 * @param *pBd - A pointer to Buffer descriptor + associated PDUs
993 * @param subType - Indicates whether it is Association Request (=0) or
994 * Reassociation Request (=1) frame
995 * @param addPreAuthContext - Indicates whether pre-auth context
996 * to be added for this STA
997 * @param authType - Indicates auth type to be added
998 * @param staId - Indicates staId of the STA being rejected
999 * association
1000 * @param deleteSta - Indicates whether to delete STA context
1001 * at Polaris
1002 * @param rCode - Indicates what reasonCode to be sent in
1003 * Re/Assoc response to STA
1004 *
1005 * @return None
1006 */
1007
1008void
1009limRejectAssociation(tpAniSirGlobal pMac, tSirMacAddr peerAddr, tANI_U8 subType,
1010 tANI_U8 addPreAuthContext, tAniAuthType authType,
1011 tANI_U16 staId, tANI_U8 deleteSta, tSirResultCodes rCode, tpPESession psessionEntry )
1012{
1013 tpDphHashNode pStaDs;
Kapil Gupta956c0c42017-06-16 19:24:31 +05301014 assoc_rsp_tx_context *tx_complete_context = NULL;
1015 vos_list_node_t *pNode= NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001016
Abhishek Singhdcbd8272014-01-09 14:16:01 +05301017 limLog(pMac, LOG1, FL("Sessionid: %d authType: %d subType: %d "
1018 "addPreAuthContext: %d staId: %d deleteSta: %d rCode : %d "
1019 "peerAddr: "MAC_ADDRESS_STR),psessionEntry->peSessionId,
1020 authType, subType, addPreAuthContext, staId, deleteSta, rCode,
1021 MAC_ADDR_ARRAY(peerAddr));
1022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 if (addPreAuthContext)
1024 {
1025 // Create entry for this STA in pre-auth list
1026 struct tLimPreAuthNode *pAuthNode;
1027
1028 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1029
1030 if (pAuthNode)
1031 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301032 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 peerAddr,
1034 sizeof(tSirMacAddr));
1035 pAuthNode->fTimerStarted = 0;
1036 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1037 pAuthNode->authType = (tAniAuthType) authType;
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301038 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 limAddPreAuthNode(pMac, pAuthNode);
1040 }
1041 }
1042
1043 if (deleteSta == true)
1044 {
1045 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
1046
1047 if (pStaDs == NULL)
1048 {
1049 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001050 FL("No STA context, yet rejecting Association"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001051
1052 return;
1053 }
Kapil Gupta956c0c42017-06-16 19:24:31 +05301054 vos_list_peek_front(&pMac->assoc_rsp_completion_list, &pNode);
1055
1056 tx_complete_context = vos_mem_malloc(sizeof(*tx_complete_context));
1057 if (!tx_complete_context)
1058 {
1059 limLog(pMac, LOGW,
1060 FL("Failed to allocate memory"));
1061
1062 return;
1063 }
1064 tx_complete_context->psessionID = psessionEntry->peSessionId;
1065 tx_complete_context->staId = staId;
1066
1067 if (pNode)
1068 vos_list_insert_back(&pMac->assoc_rsp_completion_list,
1069 &tx_complete_context->node);
1070 else
1071 vos_list_insert_front(&pMac->assoc_rsp_completion_list,
1072 &tx_complete_context->node);
Jeff Johnson295189b2012-06-20 16:38:30 -07001073
1074 /**
1075 * Polaris has state for this STA.
1076 * Trigger cleanup.
1077 */
1078 pStaDs->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 // Send Re/Association Response with
1080 // status code to requesting STA.
1081 limSendAssocRspMgmtFrame(pMac,
1082 rCode,
1083 0,
1084 peerAddr,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301085 subType, 0,psessionEntry, tx_complete_context);
Jeff Johnson295189b2012-06-20 16:38:30 -07001086
1087 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL)
1088 {
1089 // Assoction confirmation is complete, free the copy of association request frame
1090 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
1091 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301092 vos_mem_free(((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
1094 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301095 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
1097 }
Abhinav Kumara6fa29a2019-01-14 11:21:30 +05301098
1099 /* Delete hash entry on add sta failure */
1100 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
1101 limDeleteDphHashEntry(pMac, pStaDs->staAddr,
1102 pStaDs->assocId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 }
1104 else
1105 {
1106 limSendAssocRspMgmtFrame(pMac,
1107 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
1108 1,
1109 peerAddr,
Kapil Gupta956c0c42017-06-16 19:24:31 +05301110 subType, 0,psessionEntry, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 // Log error
1112 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001113 FL("received Re/Assoc req when max associated STAs reached from "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 limPrintMacAddr(pMac, peerAddr, LOGW);
1115 limSendSmeMaxAssocExceededNtf(pMac, peerAddr, psessionEntry->smeSessionId);
1116 }
1117} /*** end limRejectAssociation() ***/
1118
Jeff Johnson295189b2012-06-20 16:38:30 -07001119
1120/** -------------------------------------------------------------
1121\fn limDecideApProtectionOnHt20Delete
1122\brief protection related function while HT20 station is getting deleted.
1123\param tpAniSirGlobal pMac
1124\param tpDphHashNode pStaDs
1125\param tpUpdateBeaconParams pBeaconParams
1126\return None
1127 -------------------------------------------------------------*/
1128static void
1129limDecideApProtectionOnHt20Delete(tpAniSirGlobal pMac,
1130 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1131{
1132 tANI_U32 i = 0;
1133 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT 20 STA is disassociated. Addr is "),
1134 psessionEntry->gLimHt20Params.numSta);
1135 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1136 if (psessionEntry->gLimHt20Params.numSta > 0)
1137 {
1138 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1139 {
1140 if (psessionEntry->protStaCache[i].active)
1141 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301142 if (vos_mem_compare(psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001143 pStaDs->staAddr, sizeof(tSirMacAddr)))
1144 {
1145 psessionEntry->gLimHt20Params.numSta--;
1146 psessionEntry->protStaCache[i].active = false;
1147 break;
1148 }
1149 }
1150 }
1151 }
1152
1153 if (psessionEntry->gLimHt20Params.numSta == 0)
1154 {
1155 // disable protection
Nirav Shahbc35fb72013-12-12 18:14:06 +05301156 limLog(pMac, LOG1, FL("No 11B STA exists, PESessionID %d"),
1157 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
1159 }
1160}
1161/** -------------------------------------------------------------
1162\fn limDecideApProtectionOnDelete
1163\brief Decides about protection related settings when a station is getting deleted.
1164\param tpAniSirGlobal pMac
1165\param tpDphHashNode pStaDs
1166\param tpUpdateBeaconParams pBeaconParams
1167\return None
1168 -------------------------------------------------------------*/
1169void
1170limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
1171 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1172{
1173 tANI_U32 phyMode;
1174 tHalBitVal erpEnabled = eHAL_CLEAR;
1175 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1176 tANI_U32 i;
1177
1178 if(NULL == pStaDs)
1179 return;
1180
1181 limGetRfBand(pMac, &rfBand, psessionEntry);
1182 if(SIR_BAND_5_GHZ == rfBand)
1183 {
1184 //we are HT. if we are 11A, then protection is not required.
Jeff Johnsone7245742012-09-05 17:12:55 -07001185 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001186 {
1187 //we are HT and 11A station is leaving.
1188 //protection consideration required.
1189 //HT station leaving ==> this case is commonly handled between both the bands below.
1190 if((psessionEntry->beaconParams.llaCoexist) &&
1191 (false == pStaDs->mlmStaContext.htCapability))
1192 {
1193 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11A STA is disassociated. Addr is "),
1194 psessionEntry->gLim11aParams.numSta);
1195 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1196 if (psessionEntry->gLim11aParams.numSta > 0)
1197 {
1198 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1199 {
1200 if (psessionEntry->protStaCache[i].active)
1201 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301202 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 pStaDs->staAddr, sizeof(tSirMacAddr)))
1204 {
1205 psessionEntry->gLim11aParams.numSta--;
1206 psessionEntry->protStaCache[i].active = false;
1207 break;
1208 }
1209 }
1210 }
1211 }
1212
1213 if(psessionEntry->gLim11aParams.numSta == 0)
1214 {
1215 // disable protection
1216 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
1217 }
1218 }
1219 }
1220 }
1221 else if(SIR_BAND_2_4_GHZ == rfBand)
1222 {
1223 limGetPhyMode(pMac, &phyMode, psessionEntry);
1224
1225 erpEnabled = pStaDs->erpEnabled;
1226 //we are HT or 11G and 11B station is getting deleted.
1227 if (((phyMode == WNI_CFG_PHY_MODE_11G) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001228 psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 (erpEnabled == eHAL_CLEAR))
1230 {
1231 PELOG1(limLog(pMac, LOG1, FL("(%d) A legacy STA is disassociated. Addr is "),
1232 psessionEntry->gLim11bParams.numSta);
1233 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1234 if (psessionEntry->gLim11bParams.numSta > 0)
1235 {
1236 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1237 {
1238 if (psessionEntry->protStaCache[i].active)
1239 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301240 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 pStaDs->staAddr, sizeof(tSirMacAddr)))
1242 {
1243 psessionEntry->gLim11bParams.numSta--;
1244 psessionEntry->protStaCache[i].active = false;
1245 break;
1246 }
1247 }
1248 }
1249 }
1250
1251 if (psessionEntry->gLim11bParams.numSta == 0)
1252 {
1253 // disable protection
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 limEnable11gProtection(pMac, false, false, pBeaconParams,psessionEntry);
1255 }
1256 }
1257 //(non-11B station is leaving) or (we are not 11G or HT AP)
Jeff Johnsone7245742012-09-05 17:12:55 -07001258 else if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 { //we are HT AP and non-11B station is leaving.
1260
1261 //11g station is leaving
1262 if(!pStaDs->mlmStaContext.htCapability)
1263 {
1264 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11g STA is disassociated. Addr is "),
1265 psessionEntry->gLim11bParams.numSta);
1266 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1267 if (psessionEntry->gLim11gParams.numSta > 0)
1268 {
1269 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1270 {
1271 if (psessionEntry->protStaCache[i].active)
1272 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301273 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 pStaDs->staAddr, sizeof(tSirMacAddr)))
1275 {
1276 psessionEntry->gLim11gParams.numSta--;
1277 psessionEntry->protStaCache[i].active = false;
1278 break;
1279 }
1280 }
1281 }
1282 }
1283
1284 if (psessionEntry->gLim11gParams.numSta == 0)
1285 {
1286 // disable protection
1287 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
1288 }
1289 }
1290 }
1291 }
1292
1293 //LSIG TXOP not supporting staiton leaving. applies to 2.4 as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07001294 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 (true == pStaDs->mlmStaContext.htCapability))
1296 {
1297 //HT non-GF leaving
1298 if(!pStaDs->htGreenfield)
1299 {
1300 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-GF STA is disassociated. Addr is "),
1301 psessionEntry->gLimNonGfParams.numSta);
1302 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1303 if (psessionEntry->gLimNonGfParams.numSta > 0)
1304 {
1305 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1306 {
1307 if (psessionEntry->protStaCache[i].active)
1308 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301309 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 pStaDs->staAddr, sizeof(tSirMacAddr)))
1311 {
1312 psessionEntry->gLimNonGfParams.numSta--;
1313 psessionEntry->protStaCache[i].active = false;
1314 break;
1315 }
1316 }
1317 }
1318 }
1319
1320 if (psessionEntry->gLimNonGfParams.numSta == 0)
1321 {
1322 // disable protection
1323 limEnableHTNonGfProtection(pMac, false, false, pBeaconParams,psessionEntry);
1324 }
1325 }
1326 //HT 20Mhz station leaving.
1327 if(psessionEntry->beaconParams.ht20Coexist &&
1328 (eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet))
1329 {
1330 limDecideApProtectionOnHt20Delete(pMac, pStaDs, pBeaconParams,psessionEntry);
1331 }
1332
1333 if(false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport &&
1334 (false == pStaDs->htLsigTXOPProtection))
1335 {
1336 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is "),
1337 psessionEntry->gLimLsigTxopParams.numSta);
1338 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1339 if (psessionEntry->gLimLsigTxopParams.numSta > 0)
1340 {
1341 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1342 {
1343 if (psessionEntry->protStaCache[i].active)
1344 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301345 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 pStaDs->staAddr, sizeof(tSirMacAddr)))
1347 {
1348 psessionEntry->gLimLsigTxopParams.numSta--;
1349 psessionEntry->protStaCache[i].active = false;
1350 break;
1351 }
1352 }
1353 }
1354 }
1355
1356 if (psessionEntry->gLimLsigTxopParams.numSta == 0)
1357 {
1358 // disable protection
1359 limEnableHTLsigTxopProtection(pMac, true, false, pBeaconParams,psessionEntry);
1360 }
1361 }
1362 }
1363}
1364
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
1366
1367/** -------------------------------------------------------------
1368\fn limDecideShortPreamble
1369\brief Decides about any short preamble reated change because of new station joining.
1370\param tpAniSirGlobal pMac
1371\param tpDphHashNode pStaDs
1372\param tpUpdateBeaconParams pBeaconParams
1373\return None
1374 -------------------------------------------------------------*/
1375void limDecideShortPreamble(tpAniSirGlobal pMac,
1376 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry )
1377{
1378 tANI_U32 i;
1379
1380 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
1381 {
1382 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short preamble STA is disassociated. Addr is "),
1383 psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
1384 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1385 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta > 0)
1386 {
1387 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1388 {
1389 if (psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
1390 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301391 if (vos_mem_compare( psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 pStaDs->staAddr, sizeof(tSirMacAddr)))
1393 {
1394 psessionEntry->gLimNoShortParams.numNonShortPreambleSta--;
1395 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = false;
1396 break;
1397 }
1398 }
1399 }
1400 }
1401
1402 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta == 0)
1403 {
1404 // enable short preamble
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301406 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortParams,
1407 sizeof(tLimNoShortParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 if (limEnableShortPreamble(pMac, true, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001409 PELOGE(limLog(pMac, LOGE, FL("Cannot enable short preamble"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 }
1411 }
1412}
1413
1414/** -------------------------------------------------------------
1415\fn limDecideShortSlot
1416\brief Decides about any short slot time related change because of station leaving the BSS.
1417\param tpAniSirGlobal pMac
1418\param tpDphHashNode pStaDs
1419\return None
1420 -------------------------------------------------------------*/
1421
1422void
1423limDecideShortSlot(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1424 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1425{
1426 tANI_U32 i, val;
1427 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
1428 {
1429 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short slottime STA is disassociated. Addr is "),
1430 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
1431 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1432
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1434 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta> 0)
1435 {
1436 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1437 {
1438 if (psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1439 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301440 if (vos_mem_compare(psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 pStaDs->staAddr, sizeof(tSirMacAddr)))
1442 {
1443 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta--;
1444 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1445 break;
1446 }
1447 }
1448 }
1449 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001450 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 {
1452 if (pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta> 0)
1453 {
1454 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1455 {
1456 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1457 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301458 if (vos_mem_compare(pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001459 pStaDs->staAddr, sizeof(tSirMacAddr)))
1460 {
1461 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta--;
1462 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1463 break;
1464 }
1465 }
1466 }
1467 }
1468 }
1469
1470 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
1471
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1473 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta == 0))
1474 {
1475 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301477 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortSlotParams,
1478 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 // in case of AP set SHORT_SLOT_TIME to enable
1480 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1481 {
1482 pBeaconParams->fShortSlotTime = true;
1483 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001484 psessionEntry->shortSlotTimeSupported = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001485 }
1486 }
1487 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 {
1489 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta == 0)
1490 {
1491 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001492 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301493 vos_mem_set((tANI_U8 *)&pMac->lim.gLimNoShortSlotParams,
1494 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 // in case of AP set SHORT_SLOT_TIME to enable
1496 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1497 {
1498 pBeaconParams->fShortSlotTime = true;
1499 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001500 psessionEntry->shortSlotTimeSupported = true;
1501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 }
1503 }
1504 }
1505}
1506
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001507void
1508limPostReassocFailure(tpAniSirGlobal pMac,
1509 tSirResultCodes resultCode,
1510 tANI_U16 protStatusCode,tpPESession psessionEntry)
1511{
1512 tLimMlmReassocCnf mlmReassocCnf;
1513
1514 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1515 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
1516
1517 // 'Change' timer for future activations
1518 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1519
1520 mlmReassocCnf.resultCode = resultCode;
1521 mlmReassocCnf.protStatusCode = protStatusCode;
1522 /* Update PE session Id */
1523 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1524 limPostSmeMessage(pMac,
1525 LIM_MLM_REASSOC_CNF,
1526 (tANI_U32 *) &mlmReassocCnf);
1527} /*** end limPostReassocFailure() ***/
1528
Jeff Johnson295189b2012-06-20 16:38:30 -07001529/**
1530 * limRestorePreReassocState()
1531 *
1532 *FUNCTION:
1533 * This function is called on STA role whenever Reasociation
1534 * Response with a reject code is received from AP.
1535 *
1536 *LOGIC:
1537 * Reassociation failure timer is stopped, Old (or current) AP's
1538 * context is restored both at Polaris & software
1539 *
1540 *ASSUMPTIONS:
1541 *
1542 *NOTE:
1543 *
1544 * @param pMac - Pointer to Global MAC structure
1545 * @param resultCode - Result code that specifies why Reassociation
1546 * attemp failed
1547 *
1548 * @return None
1549 */
1550
1551void
1552limRestorePreReassocState(tpAniSirGlobal pMac,
1553 tSirResultCodes resultCode,
1554 tANI_U16 protStatusCode,tpPESession psessionEntry)
1555{
Jeff Johnsone7245742012-09-05 17:12:55 -07001556 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 tLimMlmReassocCnf mlmReassocCnf;
1558
Abhishek Singhdcbd8272014-01-09 14:16:01 +05301559 limLog(pMac, LOG1, FL("sessionid: %d protStatusCode: %d resultCode: %d"),
1560 psessionEntry->smeSessionId, protStatusCode, resultCode);
1561
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001563 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001564
1565 // 'Change' timer for future activations
1566 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1567
1568 // Update BSSID at CFG database
1569 #if 0
1570 if (cfgSetStr(pMac, WNI_CFG_BSSID,
1571 pMac->lim.gLimCurrentBssId,
1572 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1573 {
1574 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001575 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 return;
1577 }
Madan Mohan Koyyalamudi70322d52012-10-18 20:07:33 -07001578 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001579
1580 // chanNum = pMac->lim.gLimCurrentChannelId;
1581
1582 /* To support BT-AMP */
1583 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07001584 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
Jeff Johnsone7245742012-09-05 17:12:55 -07001586 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001587
1588 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1589
1590 mlmReassocCnf.resultCode = resultCode;
1591 mlmReassocCnf.protStatusCode = protStatusCode;
1592 /* Update PE session Id */
1593 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1594 limPostSmeMessage(pMac,
1595 LIM_MLM_REASSOC_CNF,
1596 (tANI_U32 *) &mlmReassocCnf);
1597} /*** end limRestorePreReassocState() ***/
1598
1599
1600
1601/**
1602 * limIsReassocInProgress()
1603 *
1604 *FUNCTION:
1605 * This function is called to see if STA is in wt-reassoc-rsp state.
1606 *
1607 *LOGIC:
1608 *
1609 *ASSUMPTIONS:
1610 *
1611 *NOTE:
1612 *
1613 * @param pMac - Pointer to Global MAC structure
1614 *
1615 * @return eANI_BOOLEAN_TRUE When STA is waiting for Reassoc response from AP \n
1616 * else eANI_BOOLEAN_FALSE
1617 */
1618
1619eAniBoolean
1620limIsReassocInProgress(tpAniSirGlobal pMac,tpPESession psessionEntry)
1621{
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001622 if (psessionEntry == NULL)
1623 {
1624 return eANI_BOOLEAN_FALSE;
1625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 if(((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1627 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1628 (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1629 return eANI_BOOLEAN_TRUE;
1630
1631 return eANI_BOOLEAN_FALSE;
1632} /*** end limIsReassocInProgress() ***/
1633
Jeff Johnsone7245742012-09-05 17:12:55 -07001634#ifdef WLAN_FEATURE_11AC
1635tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
1636 tpSirSupportedRates pRates,
1637 tDot11fIEVHTCaps *pPeerVHTCaps,
1638 tpPESession psessionEntry)
1639{
1640 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001641 tANI_U32 selfStaDot11Mode=0;
1642 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001643
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001644// if(IS_DOT11_MODE_VHT(psessionEntry->dot11mode))
1645 if (IS_DOT11_MODE_VHT(selfStaDot11Mode))
Jeff Johnsone7245742012-09-05 17:12:55 -07001646 {
1647 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_MCS_MAP,&val) !=
1648 eSIR_SUCCESS )
1649 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001650 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001651 goto error;
1652 }
1653 pRates->vhtRxMCSMap = (tANI_U16)val;
1654
1655 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_MCS_MAP,&val ) !=
1656 eSIR_SUCCESS )
1657 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001658 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT TX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001659 goto error;
1660 }
1661 pRates->vhtTxMCSMap = (tANI_U16)val;
1662
1663 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1664 eSIR_SUCCESS )
1665 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001666 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001667 goto error;
1668 }
1669 pRates->vhtRxHighestDataRate = (tANI_U16)val;
1670
1671 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1672 eSIR_SUCCESS )
1673 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001674 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001675 goto error;
1676 }
1677 pRates->vhtTxHighestDataRate = (tANI_U16)val;
1678
1679 if( pPeerVHTCaps != NULL)
1680 {
1681 pRates->vhtTxHighestDataRate = SIR_MIN(pRates->vhtTxHighestDataRate, pPeerVHTCaps->txSupDataRate);
1682 pRates->vhtRxHighestDataRate = SIR_MIN(pRates->vhtRxHighestDataRate, pPeerVHTCaps->rxHighSupDataRate);
1683
Jeff Johnson1250df42012-12-10 14:31:52 -08001684 // Acquire PEER MCS map if we exceed.
Jeff Johnsone7245742012-09-05 17:12:55 -07001685 // We compare/update only the last 2 bits of the map as we support only single BSS.
1686 // Firmware takes care of this comparison
1687 pRates->vhtRxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1688 pRates->vhtRxMCSMap |= (pPeerVHTCaps->rxMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1689
1690 // Firmware takes care of this comparison
1691 pRates->vhtTxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1692 pRates->vhtTxMCSMap |= (pPeerVHTCaps->txMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1693 }
1694 }
1695 return eSIR_SUCCESS;
1696error:
1697
1698 return eSIR_FAILURE;
1699
1700}
1701#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001702
1703/**
1704 * limPopulateOwnRateSet
1705 *
1706 * FUNCTION:
1707 * This function is called by limProcessAssocRsp() or
1708 * limAddStaInIBSS()
1709 * - It creates a combined rate set of 12 rates max which
1710 * comprises the basic and extended rates read from CFG
1711 * - It sorts the combined rate Set and copy it in the
1712 * rate array of the pSTA descriptor
1713 * - It sets the erpEnabled bit of the STA descriptor
1714 *
1715 * NOTE:
1716 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1717 * an A rate in the supported or extended rate sets
1718 *
1719 * @param pMac - Pointer to Global MAC structure
1720 * @param basicOnly - When passed value is true, only basic
1721 * rates are copied to DPH node else
1722 * all supported rates are copied
1723 * @return eSIR_SUCCESS or eSIR_FAILURE
1724 *
1725 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001726#ifdef WLAN_FEATURE_11AC
1727tSirRetStatus
1728limPopulateOwnRateSet(tpAniSirGlobal pMac,
1729 tpSirSupportedRates pRates,
1730 tANI_U8* pSupportedMCSSet,
1731 tANI_U8 basicOnly,
1732 tpPESession psessionEntry,
1733 tDot11fIEVHTCaps *pVHTCaps)
1734#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001735tSirRetStatus
1736limPopulateOwnRateSet(tpAniSirGlobal pMac,
1737 tpSirSupportedRates pRates,
1738 tANI_U8* pSupportedMCSSet,
1739 tANI_U8 basicOnly,
1740 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001741#endif
1742
Jeff Johnson295189b2012-06-20 16:38:30 -07001743{
1744 tSirMacRateSet tempRateSet;
1745 tSirMacRateSet tempRateSet2;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301746 tANI_U32 i,j,val,min,isArate;
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 tANI_U32 phyMode = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001748 tANI_U32 selfStaDot11Mode=0;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301749
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 isArate = 0;
1751
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001752 wlan_cfgGetInt(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001753 limGetPhyMode(pMac, &phyMode, psessionEntry);
1754
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301755 /* Include 11b rates only when the device configured in
1756 auto, 11a/b/g or 11b_only */
1757 if ( (selfStaDot11Mode == WNI_CFG_DOT11_MODE_ALL) ||
1758 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11A) ||
1759 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11AC) ||
Leela Venkata Kiran Kumar Reddy Chiralac9a10e52013-08-29 16:37:15 -07001760 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11N) ||
1761 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11G) ||
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301762 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11B) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301764 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1765 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11B,
1766 (tANI_U8 *)&tempRateSet.rate, &val );
1767 tempRateSet.numRates = (tANI_U8) val;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001768 }
1769 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301770 tempRateSet.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001771
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301772 /* Include 11a rates when the device configured in non-11b mode */
1773 if (!IS_DOT11_MODE_11B(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301775 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1776 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11A,
1777 (tANI_U8 *)&tempRateSet2.rate, &val );
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 tempRateSet2.numRates = (tANI_U8) val;
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 }
1780 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301781 tempRateSet2.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001782
1783 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1784 {
1785 //we are in big trouble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001786 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 //panic
1788 goto error;
1789 }
1790
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 //copy all rates in tempRateSet, there are 12 rates max
1792 for (i = 0;i < tempRateSet2.numRates; i++)
1793 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1794 tempRateSet.numRates += tempRateSet2.numRates;
1795
1796 /**
1797 * Sort rates in tempRateSet (they are likely to be already sorted)
1798 * put the result in pSupportedRates
1799 */
1800 {
1801 tANI_U8 aRateIndex = 0;
1802 tANI_U8 bRateIndex = 0;
1803
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301804 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 for(i = 0;i < tempRateSet.numRates; i++)
1806 {
1807 min = 0;
1808 val = 0xff;
1809 isArate = 0;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001810 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 {
1812 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1813 {
1814 val = tempRateSet.rate[j] & 0x7f;
1815 min = j;
1816 }
1817 }
1818
1819 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1820 isArate = 1;
1821
1822 /*
1823 * HAL needs to know whether the rate is basic rate or not, as it needs to
1824 * update the response rate table accordingly. e.g. if one of the 11a rates is
1825 * basic rate, then that rate can be used for sending control frames.
1826 * HAL updates the response rate table whenever basic rate set is changed.
1827 */
1828 if (basicOnly)
1829 {
1830 if (tempRateSet.rate[min] & 0x80)
1831 {
1832 if (isArate)
1833 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1834 else
1835 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1836 }
1837 }
1838 else
1839 {
1840 if (isArate)
1841 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1842 else
1843 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1844 }
1845 tempRateSet.rate[min] = 0xff;
1846 }
1847
1848 }
1849
1850
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001851 //if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1852 if (IS_DOT11_MODE_HT(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 {
1854 val = SIZE_OF_SUPPORTED_MCS_SET;
1855 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1856 pRates->supportedMCSSet,
1857 &val) != eSIR_SUCCESS)
1858 {
1859 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001860 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 goto error;
1862 }
1863
1864
1865 //if supported MCS Set of the peer is passed in, then do the intersection
1866 //else use the MCS set from local CFG.
1867
1868 if(pSupportedMCSSet != NULL)
1869 {
1870 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1871 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1872
1873 }
1874
Abhishek Singh525045c2014-12-15 17:18:45 +05301875 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05301877 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 }
1879
Jeff Johnsone7245742012-09-05 17:12:55 -07001880#ifdef WLAN_FEATURE_11AC
1881 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1882#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001883
1884 return eSIR_SUCCESS;
1885
1886 error:
1887
1888 return eSIR_FAILURE;
1889} /*** limPopulateOwnRateSet() ***/
1890
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001891#ifdef WLAN_FEATURE_11AC
1892tSirRetStatus
1893limPopulatePeerRateSet(tpAniSirGlobal pMac,
1894
1895 tpSirSupportedRates pRates,
1896 tANI_U8* pSupportedMCSSet,
1897 tANI_U8 basicOnly,
1898 tpPESession psessionEntry,
1899 tDot11fIEVHTCaps *pVHTCaps)
1900#else
1901tSirRetStatus
1902limPopulatePeerRateSet(tpAniSirGlobal pMac,
1903 tpSirSupportedRates pRates,
1904 tANI_U8* pSupportedMCSSet,
1905 tANI_U8 basicOnly,
1906 tpPESession psessionEntry)
1907#endif
1908{
1909 tSirMacRateSet tempRateSet;
1910 tSirMacRateSet tempRateSet2;
1911 tANI_U32 i,j,val,min,isArate;
1912 isArate = 0;
1913
1914 /* copy operational rate set from psessionEntry */
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001915 if ( psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX )
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001916 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301917 vos_mem_copy((tANI_U8 *)tempRateSet.rate,
1918 (tANI_U8*)(psessionEntry->rateSet.rate),
1919 psessionEntry->rateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001920 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1921 }
1922 else
1923 {
1924 limLog(pMac, LOGE, FL("more than SIR_MAC_RATESET_EID_MAX rates\n"));
1925 goto error;
1926 }
Leela Venkata Kiran Kumar Reddy Chirala891bf062013-10-03 14:30:53 -07001927 if ((psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1928 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1929 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11N))
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001930 {
1931
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001932 if (psessionEntry->extRateSet.numRates <= SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001933 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301934 vos_mem_copy((tANI_U8 *)tempRateSet2.rate,
1935 (tANI_U8*)(psessionEntry->extRateSet.rate),
1936 psessionEntry->extRateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001937 tempRateSet2.numRates = psessionEntry->extRateSet.numRates;
1938 }
1939 else {
1940 limLog(pMac, LOGE, FL("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates\n"));
1941 goto error;
1942 }
1943 }
1944 else
1945 tempRateSet2.numRates = 0;
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001946 if ((tempRateSet.numRates + tempRateSet2.numRates) > SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001947 {
1948 //we are in big trouble
1949 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
1950 goto error;
1951 }
1952
1953
1954 //copy all rates in tempRateSet, there are 12 rates max
1955 for (i = 0;i < tempRateSet2.numRates; i++)
1956 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1957 tempRateSet.numRates += tempRateSet2.numRates;
1958 /**
1959 * Sort rates in tempRateSet (they are likely to be already sorted)
1960 * put the result in pSupportedRates
1961 */
1962 {
1963 tANI_U8 aRateIndex = 0;
1964 tANI_U8 bRateIndex = 0;
Kiet Lam842c3e12013-11-16 22:40:57 +05301965 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001966 for(i = 0;i < tempRateSet.numRates; i++)
1967 {
1968 min = 0;
1969 val = 0xff;
1970 isArate = 0;
1971 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
1972 {
1973 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1974 {
1975 val = tempRateSet.rate[j] & 0x7f;
1976 min = j;
1977 }
1978 }
1979 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1980 isArate = 1;
1981 /*
1982 * HAL needs to know whether the rate is basic rate or not, as it needs to
1983 * update the response rate table accordingly. e.g. if one of the 11a rates is
1984 * basic rate, then that rate can be used for sending control frames.
1985 * HAL updates the response rate table whenever basic rate set is changed.
1986 */
1987 if (basicOnly)
1988 {
1989 if (tempRateSet.rate[min] & 0x80)
1990 {
1991 if (isArate)
1992 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1993 else
1994 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1995 }
1996 }
1997 else
1998 {
1999 if (isArate)
2000 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
2001 else
2002 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
2003 }
2004 tempRateSet.rate[min] = 0xff;
2005 }
2006 }
2007
2008
2009 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode))
2010 {
2011 val = SIZE_OF_SUPPORTED_MCS_SET;
2012 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2013 pRates->supportedMCSSet,
2014 &val) != eSIR_SUCCESS)
2015 {
2016 /// Could not get rateset from CFG. Log error.
2017 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
2018 goto error;
2019 }
2020 //if supported MCS Set of the peer is passed in, then do the intersection
2021 //else use the MCS set from local CFG.
2022 if(pSupportedMCSSet != NULL)
2023 {
2024 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2025 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
2026 }
Abhishek Singh525045c2014-12-15 17:18:45 +05302027 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002028 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05302029 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002030 }
2031#ifdef WLAN_FEATURE_11AC
2032 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
2033#endif
2034 return eSIR_SUCCESS;
2035 error:
2036 return eSIR_FAILURE;
2037} /*** limPopulatePeerRateSet() ***/
2038
Jeff Johnson295189b2012-06-20 16:38:30 -07002039/**
2040 * limPopulateMatchingRateSet
2041 * FUNCTION:
2042 * This is called at the time of Association Request
2043 * processing on AP and while adding peer's context
2044 * in IBSS role to process the CFG rate sets and
2045 * the rate sets received in the Assoc request on AP
2046 * or Beacon/Probe Response from peer in IBSS.
2047 *
2048 * LOGIC:
2049 * 1. It makes the intersection between our own rate Sat
2050 * and extemcded rate set and the ones received in the
2051 * association request.
2052 * 2. It creates a combined rate set of 12 rates max which
2053 * comprised the basic and extended rates
2054 * 3. It sorts the combined rate Set and copy it in the
2055 * rate array of the pSTA descriptor
2056 *
2057 * ASSUMPTION:
2058 * The parser has already ensured unicity of the rates in the
2059 * association request structure
2060 *
2061 * @param: pMac - Pointer to Global MAC structure
2062 * pStaDs - Pointer to DPH node
2063 * pOperRateSet - Pointer to peer's supported rateset
2064 * pExtRateSet - Pointer to peer's extended rateset
2065 *
2066 * @return: eSIR_SUCCESS or eSIR_FAILURE
2067 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002068#ifdef WLAN_FEATURE_11AC
2069tSirRetStatus
2070limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2071 tpDphHashNode pStaDs,
2072 tSirMacRateSet *pOperRateSet,
2073 tSirMacRateSet *pExtRateSet,
2074 tANI_U8* pSupportedMCSSet,
2075 tSirMacPropRateSet *pAniLegRateSet,
2076 tpPESession psessionEntry,
2077 tDot11fIEVHTCaps *pVHTCaps)
Jeff Johnson295189b2012-06-20 16:38:30 -07002078
Jeff Johnsone7245742012-09-05 17:12:55 -07002079#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002080tSirRetStatus
2081limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2082 tpDphHashNode pStaDs,
2083 tSirMacRateSet *pOperRateSet,
2084 tSirMacRateSet *pExtRateSet,
2085 tANI_U8* pSupportedMCSSet,
2086 tSirMacPropRateSet *pAniLegRateSet,
2087 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07002088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002089{
2090 tSirMacRateSet tempRateSet;
2091 tSirMacRateSet tempRateSet2;
2092 tANI_U32 i,j,val,min,isArate;
2093 tANI_U32 phyMode;
2094 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2095
2096 isArate=0;
2097
2098 // limGetPhyMode(pMac, &phyMode);
2099 limGetPhyMode(pMac, &phyMode, psessionEntry);
2100
2101 // get own rate set
2102 // val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2103 #if 0
2104 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2105 (tANI_U8 *) &tempRateSet.rate,
2106 &val) != eSIR_SUCCESS)
2107 {
2108 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002109 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002110 }
2111
2112 #endif // TO SUPPORT BT-AMP
2113
2114 /* copy operational rate set from psessionEntry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302115 vos_mem_copy((tempRateSet.rate), (psessionEntry->rateSet.rate),
2116 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 tempRateSet.numRates = (tANI_U8) psessionEntry->rateSet.numRates;
2118
2119 if (phyMode == WNI_CFG_PHY_MODE_11G)
2120 {
2121
2122 #if 0
2123 // get own extended rate set
2124 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2125 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
2126 (tANI_U8 *) &tempRateSet2.rate,
2127 &val) != eSIR_SUCCESS)
2128 #endif
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302129 vos_mem_copy((tempRateSet2.rate), (psessionEntry->extRateSet.rate),
2130 psessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 tempRateSet2.numRates = (tANI_U8) psessionEntry->extRateSet.numRates;
2132 }
2133 else
2134 tempRateSet2.numRates = 0;
2135
2136 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2137 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002138 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 goto error;
2140 }
2141
2142 /**
2143 * Handling of the rate set IEs is the following:
2144 * - keep only rates that we support and that the station supports
2145 * - sort and the rates into the pSta->rate array
2146 */
2147
2148 // Copy all rates in tempRateSet, there are 12 rates max
2149 for(i = 0; i < tempRateSet2.numRates; i++)
2150 tempRateSet.rate[i + tempRateSet.numRates] =
2151 tempRateSet2.rate[i];
2152
2153 tempRateSet.numRates += tempRateSet2.numRates;
2154
2155 /**
2156 * Sort rates in tempRateSet (they are likely to be already sorted)
2157 * put the result in tempRateSet2
2158 */
2159 tempRateSet2.numRates = 0;
2160
2161 for(i = 0;i < tempRateSet.numRates; i++)
2162 {
2163 min = 0;
2164 val = 0xff;
2165
2166 for(j = 0;j < tempRateSet.numRates; j++)
2167 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2168 {
2169 val = tempRateSet.rate[j] & 0x7f;
2170 min = j;
2171 }
2172
2173 tempRateSet2.rate[tempRateSet2.numRates++] =
2174 tempRateSet.rate[min];
2175 tempRateSet.rate[min] = 0xff;
2176 }
2177
2178
2179 /**
2180 * Copy received rates in tempRateSet, the parser has ensured
2181 * unicity of the rates so there cannot be more than 12
2182 */
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002183 for(i = 0; (i < pOperRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 {
2185 tempRateSet.rate[i] = pOperRateSet->rate[i];
2186 }
2187
2188 tempRateSet.numRates = pOperRateSet->numRates;
2189
2190 if (pExtRateSet->numRates)
2191 {
2192 if((tempRateSet.numRates + pExtRateSet->numRates) > 12 )
2193 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302194 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 "Sum of SUPPORTED and EXTENDED Rate Set (%1d) exceeds 12!",
2196 tempRateSet.numRates + pExtRateSet->numRates );
2197
2198 if( tempRateSet.numRates < 12 )
2199 {
2200 int found = 0;
2201 int tail = tempRateSet.numRates;
2202
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002203 for( i = 0; (i < pExtRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX); i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 {
2205 found = 0;
2206 for( j = 0; j < (tANI_U32) tail; j++ )
2207 {
2208 if((tempRateSet.rate[j] & 0x7F) ==
2209 (pExtRateSet->rate[i] & 0x7F))
2210 {
2211 found = 1;
2212 break;
2213 }
2214 }
2215
2216 if( !found )
2217 {
2218 tempRateSet.rate[tempRateSet.numRates++] =
2219 pExtRateSet->rate[i];
2220
2221 if( tempRateSet.numRates >= 12 )
2222 break;
2223 }
2224 }
2225 }
2226 else
Abhishek Singh525045c2014-12-15 17:18:45 +05302227 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 "Relying only on the SUPPORTED Rate Set IE..." );
2229 }
2230 else
2231 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002232 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 -07002233 tempRateSet.rate[i+j] = pExtRateSet->rate[j];
2234
2235 tempRateSet.numRates += pExtRateSet->numRates;
2236 }
2237 }
2238
2239 {
2240 tpSirSupportedRates rates = &pStaDs->supportedRates;
2241 tANI_U8 aRateIndex = 0;
2242 tANI_U8 bRateIndex = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302243 vos_mem_set((tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002244 for(i = 0;(i < tempRateSet2.numRates && i < SIR_MAC_RATESET_EID_MAX ); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002246 for(j = 0;(j < tempRateSet.numRates && j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 {
2248 if ((tempRateSet2.rate[i] & 0x7F) ==
2249 (tempRateSet.rate[j] & 0x7F))
2250 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2252 {
2253 isArate=1;
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002254 if (aRateIndex < SIR_NUM_11A_RATES)
2255 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 }
2257 else
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002258 {
2259 if (bRateIndex < SIR_NUM_11B_RATES)
2260 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 break;
2263 }
2264 }
2265 }
2266
2267
2268 //Now add the Polaris rates only when Proprietary rates are enabled.
2269 val = 0;
2270 if(wlan_cfgGetInt(pMac, WNI_CFG_PROPRIETARY_RATES_ENABLED, &val) != eSIR_SUCCESS)
2271 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002272 limLog(pMac, LOGP, FL("could not retrieve prop rate enabled flag from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 }
2274 else if(val)
2275 {
2276 for(i=0; i<pAniLegRateSet->numPropRates; i++)
2277 rates->aniLegacyRates[i] = pAniLegRateSet->propRate[i];
2278 }
2279
2280 }
2281
2282
2283 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002284#ifdef FEATURE_WLAN_TDLS
2285 if(pStaDs->mlmStaContext.htCapability)
2286#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2288 (pStaDs->mlmStaContext.htCapability))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 {
2291 val = SIZE_OF_SUPPORTED_MCS_SET;
2292 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2293 mcsSet,
2294 &val) != eSIR_SUCCESS)
2295 {
2296 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002297 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 goto error;
2299 }
2300
2301 for(i=0; i<val; i++)
2302 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2303
Abhishek Singh525045c2014-12-15 17:18:45 +05302304 limLog(pMac, LOG1, FL(" MCS Rate Set Bitmap from CFG and DPH : "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2306 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302307 limLog(pMac, LOG1,FL("%x %x "), mcsSet[i],
2308 pStaDs->supportedRates.supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 }
2310 }
2311
Jeff Johnsone7245742012-09-05 17:12:55 -07002312#ifdef WLAN_FEATURE_11AC
2313 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2314#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 /**
2316 * Set the erpEnabled bit iff the phy is in G mode and at least
2317 * one A rate is supported
2318 */
2319 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2320 pStaDs->erpEnabled = eHAL_SET;
2321
2322
2323
2324 return eSIR_SUCCESS;
2325
2326 error:
2327
2328 return eSIR_FAILURE;
2329} /*** limPopulateMatchingRateSet() ***/
2330
2331
2332
2333/**
2334 * limAddSta()
2335 *
2336 *FUNCTION:
2337 * This function is called to add an STA context at hardware
2338 * whenever a STA is (Re) Associated.
2339 *
2340 *LOGIC:
2341 *
2342 *ASSUMPTIONS:
2343 * NA
2344 *
2345 *NOTE:
2346 * NA
2347 *
2348 * @param pMac - Pointer to Global MAC structure
2349 * @param pStaDs - Pointer to the STA datastructure created by
2350 * LIM and maintained by DPH
2351 * @return retCode - Indicates success or failure return code
2352 */
2353
2354tSirRetStatus
2355limAddSta(
2356 tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002357 tpDphHashNode pStaDs, tANI_U8 updateEntry, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002358{
2359 tpAddStaParams pAddStaParams = NULL;
2360 tSirMsgQ msgQ;
2361 tSirRetStatus retCode = eSIR_SUCCESS;
2362 tSirMacAddr staMac, *pStaAddr;
2363 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002364 tpSirAssocReq pAssocReq;
2365 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 #if 0
2367 retCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2368 if (retCode != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002369 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 #endif //To SUPPORT BT-AMP
2371
2372
2373 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2374
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302375 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
2376 psessionEntry->smeSessionId, updateEntry, psessionEntry->limSystemRole);
2377
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302378 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2379 if (NULL == pAddStaParams)
2380 {
2381 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
2382 return eSIR_MEM_ALLOC_FAILED;
2383 }
2384 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||
2387 (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE) ||
2388 (limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) )
2389 pStaAddr = &pStaDs->staAddr;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002390#ifdef FEATURE_WLAN_TDLS
2391 /* SystemRole shouldn't be matter if staType is TDLS peer */
2392 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2393 {
2394 pStaAddr = &pStaDs->staAddr ;
2395 }
2396#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 else
2398 pStaAddr = &staMac;
2399
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302400 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": Subtype(Assoc/Reassoc): %d "),
2401 MAC_ADDR_ARRAY(*pStaAddr), pStaDs->mlmStaContext.subType);
2402
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302403 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2404 (tANI_U8 *) *pStaAddr, sizeof(tSirMacAddr));
2405 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2406 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002407
2408 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
2409
2410 //Copy legacy rates
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302411 vos_mem_copy ((tANI_U8*)&pAddStaParams->supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07002412 (tANI_U8*)&pStaDs->supportedRates, sizeof(tSirSupportedRates));
2413
2414 pAddStaParams->assocId = pStaDs->assocId;
2415
2416 pAddStaParams->wmmEnabled = pStaDs->qosMode;
2417 pAddStaParams->listenInterval = pStaDs->mlmStaContext.listenInterval;
2418 pAddStaParams->shortPreambleSupported = pStaDs->shortPreambleEnabled;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302419 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 if((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) && (pStaDs->mlmStaContext.subType == LIM_REASSOC))
2421 {
2422 /* TBD - need to remove this REASSOC check after fixinf rmmod issue */
2423 pAddStaParams->updateSta = pStaDs->mlmStaContext.updateContext;
2424 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 pStaDs->valid = 0;
2426 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2427
Abhishek Singh525045c2014-12-15 17:18:45 +05302428 limLog(pMac, LOG1, FL(" Assoc ID: %d wmmEnabled = %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302429 " shortPreambleSupported: %d "), pAddStaParams->assocId,
2430 pAddStaParams->wmmEnabled, pAddStaParams->listenInterval,
2431 pAddStaParams->shortPreambleSupported);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002432 // This will indicate HAL to "allocate" a new STA index
2433#ifdef FEATURE_WLAN_TDLS
2434 /* As there is corner case in-between add_sta and change_sta,if del_sta for other staIdx happened,
2435 * firmware return wrong staIdx (recently removed staIdx). Until we get a confirmation from the
2436 * firmware team it is now return correct staIdx for same sta_mac_addr for update case, we want
2437 * to get around it by passing valid staIdx given by add_sta time.
2438 */
2439 if((STA_ENTRY_TDLS_PEER == pStaDs->staType) &&
2440 (true == updateEntry))
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302441 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002442 pAddStaParams->staIdx = pStaDs->staIndex;
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302443 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002444 else
2445#endif
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302446#ifdef SAP_AUTH_OFFLOAD
2447 if (!pMac->sap_auth_offload)
2448 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2449 else
2450 pAddStaParams->staIdx = pStaDs->staIndex;
2451#else
2452 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2453#endif
2454
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 pAddStaParams->staType = pStaDs->staType;
2456
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002457 pAddStaParams->updateSta = updateEntry;
2458
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2460 pAddStaParams->respReqd = 1;
2461 //Update HT Capability
2462
2463 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 -07002464 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Jeff Johnsone7245742012-09-05 17:12:55 -07002466#ifdef WLAN_FEATURE_11AC
2467 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2468#endif
2469 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002470#ifdef FEATURE_WLAN_TDLS
2471 /* SystemRole shouldn't be matter if staType is TDLS peer */
2472 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
Hoonki Lee99e53782013-02-12 18:07:03 -08002473 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002474 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Hoonki Lee99e53782013-02-12 18:07:03 -08002475#ifdef WLAN_FEATURE_11AC
2476 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2477#endif
2478 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002479#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 else
Jeff Johnsone7245742012-09-05 17:12:55 -07002481 {
2482 pAddStaParams->htCapable = psessionEntry->htCapability;
2483#ifdef WLAN_FEATURE_11AC
2484 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
2485#endif
2486
2487 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302488#ifdef WLAN_FEATURE_11AC
Abhishek Singh525045c2014-12-15 17:18:45 +05302489 limLog(pMac, LOG1, FL("vhtCapable: %d "), pAddStaParams->vhtCapable);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302490#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302491 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302492 pAddStaParams->staIdx,pAddStaParams->updateSta,
2493 pAddStaParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002494
2495 pAddStaParams->greenFieldCapable = pStaDs->htGreenfield;
2496 pAddStaParams->maxAmpduDensity= pStaDs->htAMpduDensity;
2497 pAddStaParams->maxAmpduSize = pStaDs->htMaxRxAMpduFactor;
2498 pAddStaParams->fDsssCckMode40Mhz = pStaDs->htDsssCckRate40MHzSupport;
2499 pAddStaParams->fShortGI20Mhz = pStaDs->htShortGI20Mhz;
2500 pAddStaParams->fShortGI40Mhz = pStaDs->htShortGI40Mhz;
2501 pAddStaParams->lsigTxopProtection = pStaDs->htLsigTXOPProtection;
2502 pAddStaParams->maxAmsduSize = pStaDs->htMaxAmsduLength;
2503 pAddStaParams->txChannelWidthSet = pStaDs->htSupportedChannelWidthSet;
2504 pAddStaParams->mimoPS = pStaDs->htMIMOPSState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002505
Abhishek Singh525045c2014-12-15 17:18:45 +05302506 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302507 "maxAmpduDensity = %d"), pAddStaParams->greenFieldCapable,
2508 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
2509
Abhishek Singh525045c2014-12-15 17:18:45 +05302510 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302511 "fShortGI40Mhz: %d"), pAddStaParams->fDsssCckMode40Mhz,
2512 pAddStaParams->fShortGI20Mhz, pAddStaParams->fShortGI40Mhz);
2513
Abhishek Singh525045c2014-12-15 17:18:45 +05302514 limLog(pMac, LOG1, FL("lsigTxopProtection: %d maxAmsduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302515 "txChannelWidthSet: %d mimoPS: %d "), pAddStaParams->lsigTxopProtection,
2516 pAddStaParams->maxAmsduSize,pAddStaParams->txChannelWidthSet,
2517 pAddStaParams->mimoPS);
2518
Jeff Johnsone7245742012-09-05 17:12:55 -07002519#ifdef WLAN_FEATURE_11AC
2520 if(pAddStaParams->vhtCapable)
2521 {
Mohit Khanna7d5aeb22012-09-11 16:21:57 -07002522 pAddStaParams->vhtTxChannelWidthSet = pStaDs->vhtSupportedChannelWidthSet;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002523 pAddStaParams->vhtTxBFCapable =
Hoonki Lee99e53782013-02-12 18:07:03 -08002524#ifdef FEATURE_WLAN_TDLS
2525 (( STA_ENTRY_PEER == pStaDs->staType ) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) ?
2526 pStaDs->vhtBeamFormerCapable : psessionEntry->txBFIniFeatureEnabled ;
2527#else
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002528 ( STA_ENTRY_PEER == pStaDs->staType ) ? pStaDs->vhtBeamFormerCapable :
2529 psessionEntry->txBFIniFeatureEnabled ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002530#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302531 limLog(pMac, LOG1, FL("vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302532 pAddStaParams->vhtTxChannelWidthSet,pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07002533 }
2534#endif
2535
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002536#ifdef FEATURE_WLAN_TDLS
2537 if((STA_ENTRY_PEER == pStaDs->staType) ||
2538 (STA_ENTRY_TDLS_PEER == pStaDs->staType))
2539#else
2540 if (STA_ENTRY_PEER == pStaDs->staType)
2541#endif
2542 {
2543 /* peer STA get the LDPC capability from pStaDs, which populated from
2544 * HT/VHT capability*/
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05302545 if(pAddStaParams->vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP)
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002546 {
2547 pAddStaParams->htLdpcCapable = 0;
2548 pAddStaParams->vhtLdpcCapable = 0;
2549 }
2550 else
2551 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05302552 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
2553 pAddStaParams->htLdpcCapable = pStaDs->htLdpcCapable;
2554 else
2555 pAddStaParams->htLdpcCapable = 0;
2556 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
2557 pAddStaParams->vhtLdpcCapable = pStaDs->vhtLdpcCapable;
2558 else
2559 pAddStaParams->vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002560 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002561 }
2562 else if( STA_ENTRY_SELF == pStaDs->staType)
2563 {
2564 /* For Self STA get the LDPC capability from config.ini*/
2565 pAddStaParams->htLdpcCapable =
2566 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2567 pAddStaParams->vhtLdpcCapable =
2568 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2569 }
2570
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 /* Update PE session ID*/
2572 pAddStaParams->sessionId = psessionEntry->peSessionId;
2573
2574 if (psessionEntry->parsedAssocReq != NULL)
2575 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 // Get a copy of the already parsed Assoc Request
2577 pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pStaDs->assocId];
2578 if ( pAssocReq && pAssocReq->addIEPresent && pAssocReq->addIE.length ) {
2579 p2pIe = limGetP2pIEPtr(pMac, pAssocReq->addIE.addIEdata, pAssocReq->addIE.length);
2580 }
2581 pAddStaParams->p2pCapableSta = (p2pIe != NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 }
2583
2584 //Disable BA. It will be set as part of ADDBA negotiation.
2585 for( i = 0; i < STACFG_MAX_TC; i++ )
2586 {
2587 pAddStaParams->staTCParams[i].txUseBA = eBA_DISABLE;
2588 pAddStaParams->staTCParams[i].rxUseBA = eBA_DISABLE;
2589 }
2590
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002591#ifdef FEATURE_WLAN_TDLS
2592 if(pStaDs->wmeEnabled && \
2593 ((eLIM_AP_ROLE == psessionEntry->limSystemRole) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) )
2594#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 if(pStaDs->wmeEnabled && (eLIM_AP_ROLE == psessionEntry->limSystemRole))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002596#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 {
2598 pAddStaParams->uAPSD = 0;
2599 /* update UAPSD and send it to LIM to add STA */
2600 // bitmap MSB <- LSB MSB 4 bits are for
2601 // trigger enabled AC setting and LSB 4 bits
2602 // are for delivery enabled AC setting
2603 // 7 6 5 4 3 2 1 0
2604 // BE BK VI VO BE BK VI VO
2605 pAddStaParams->uAPSD |= pStaDs->qos.capability.qosInfo.acvo_uapsd;
2606 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acvi_uapsd << 1);
2607 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbk_uapsd << 2);
2608 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbe_uapsd << 3);
2609 //making delivery enabled and trigger enabled setting the same.
2610 pAddStaParams->uAPSD |= pAddStaParams->uAPSD << 4;
2611
2612 pAddStaParams->maxSPLen = pStaDs->qos.capability.qosInfo.maxSpLen;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302613 limLog( pMac, LOG1, FL("uAPSD = 0x%x, maxSpLen = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 pAddStaParams->uAPSD, pAddStaParams->maxSPLen);
2615 }
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002616
2617#ifdef WLAN_FEATURE_11W
2618 pAddStaParams->rmfEnabled = pStaDs->rmfEnabled;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302619 limLog( pMac, LOG1, FL( "PMF enabled %d"), pAddStaParams->rmfEnabled);
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002620#endif
2621
Abhishek Singh525045c2014-12-15 17:18:45 +05302622 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302623 "p2pCapableSta: %d"), pAddStaParams->htLdpcCapable,
2624 pAddStaParams->vhtLdpcCapable, pAddStaParams->p2pCapableSta);
2625
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302626#ifdef SAP_AUTH_OFFLOAD
2627 if (pMac->sap_auth_offload) {
2628 pAddStaParams->dpuIndex = pStaDs->dpuIndex;
2629 pAddStaParams->bcastDpuIndex = pStaDs->bcastDpuIndex;
2630 pAddStaParams->bcastMgmtDpuIdx = pStaDs->bcastMgmtDpuIdx;
2631 pAddStaParams->ucUcastSig = pStaDs->ucUcastSig;
2632 pAddStaParams->ucBcastSig = pStaDs->ucBcastSig;
2633 pAddStaParams->ucMgmtSig = pStaDs->ucMgmtSig;
Agrawal Ashishce67f362017-01-05 20:10:58 +05302634 pAddStaParams->bssIdx = pStaDs->bssId;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302635 }
2636#endif
2637
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002638 //we need to defer the message until we get the response back from HAL.
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 if (pAddStaParams->respReqd)
2640 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002641
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302642#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302643 if (pMac->sap_auth_offload && LIM_IS_AP_ROLE(psessionEntry))
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302644 msgQ.type = WDA_SAP_OFL_ADD_STA;
2645 else
2646 msgQ.type = WDA_ADD_STA_REQ;
2647#else
2648 msgQ.type = WDA_ADD_STA_REQ;
2649#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002650
2651 msgQ.reserved = 0;
2652 msgQ.bodyptr = pAddStaParams;
2653 msgQ.bodyval = 0;
2654
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002655 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ for assocId %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 pStaDs->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002657 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002658
2659 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2660 if( eSIR_SUCCESS != retCode)
2661 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002662 if (pAddStaParams->respReqd)
2663 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002664 limLog( pMac, LOGE, FL("ADD_STA_REQ for aId %d failed (reason %X)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 pStaDs->assocId, retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302666 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 }
2668
2669 return retCode;
2670}
2671
2672
2673/**
2674 * limDelSta()
2675 *
2676 *FUNCTION:
2677 * This function is called to delete an STA context at hardware
2678 * whenever a STA is disassociated
2679 *
2680 *LOGIC:
2681 *
2682 *ASSUMPTIONS:
2683 * NA
2684 *
2685 *NOTE:
2686 * NA
2687 *
2688 * @param pMac - Pointer to Global MAC structure
2689 * @param pStaDs - Pointer to the STA datastructure created by
2690 * LIM and maintained by DPH
2691 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2692 * or not (false)
2693 * @return retCode - Indicates success or failure return code
2694 */
2695
2696tSirRetStatus
2697limDelSta(
2698 tpAniSirGlobal pMac,
2699 tpDphHashNode pStaDs,
2700 tANI_BOOLEAN fRespReqd,
2701 tpPESession psessionEntry)
2702{
2703 tpDeleteStaParams pDelStaParams = NULL;
2704 tSirMsgQ msgQ;
2705 tSirRetStatus retCode = eSIR_SUCCESS;
Sravan Kumar Kairam18705ef2017-09-21 18:37:50 +05302706 tANI_U8 channelNum = 0;
2707 tANI_U32 cfgValue = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002708
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302709 pDelStaParams = vos_mem_malloc(sizeof( tDeleteStaParams ));
2710 if (NULL == pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302712 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 return eSIR_MEM_ALLOC_FAILED;
2714 }
2715
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302716 vos_mem_set((tANI_U8 *) pDelStaParams, sizeof(tDeleteStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002717
Sravan Kumar Kairam18705ef2017-09-21 18:37:50 +05302718 wlan_cfgGetInt(pMac, WNI_CFG_ACTIVE_PASSIVE_CON, &cfgValue);
2719
2720 channelNum = limGetCurrentOperatingChannel(pMac);
2721 limLog(pMac, LOG1, FL("Current Operating channel is %d"), channelNum);
2722 if (!cfgValue && (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) &&
2723 limIsconnectedOnDFSChannel(channelNum))
2724 {
2725 limCovertChannelScanType(pMac, channelNum, false);
2726 pMac->lim.dfschannelList.timeStamp[channelNum] = 0;
2727 }
2728
2729
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 //
2731 // DPH contains the STA index only for "peer" STA entries.
2732 // LIM global contains "self" STA index
2733 // Thus,
2734 // if( STA role )
2735 // get STA index from LIM global
2736 // else
2737 // get STA index from DPH
2738 //
2739
2740#if 0
2741 /* Since we have not created any STA, no need to send msg to delete
2742 * STA to HAL */
2743 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
2744 pDelStaParams->staIdx = 1; /* TODO : This is workaround. Need to find right STA Index before sending to HAL */
2745 //return retCode;
2746 }
2747#endif
2748
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002749#ifdef FEATURE_WLAN_TDLS
2750 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)) )
2751#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 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 -08002753#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 pDelStaParams->staIdx= psessionEntry->staId;
2755
2756 else
2757 pDelStaParams->staIdx= pStaDs->staIndex;
2758
2759 pDelStaParams->assocId = pStaDs->assocId;
2760 pStaDs->valid = 0;
2761
2762 if (! fRespReqd)
2763 pDelStaParams->respReqd = 0;
2764 else
2765 {
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302766 if (pStaDs->staType != STA_ENTRY_TDLS_PEER) {
2767 /**
2768 * when limDelSta is called from processSmeAssocCnf
2769 * then mlmState is already set properly.
2770 */
2771 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
2772 GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs)) {
2773 MTRACE(macTrace
2774 (pMac, TRACE_CODE_MLM_STATE,
2775 psessionEntry->peSessionId,
2776 eLIM_MLM_WT_DEL_STA_RSP_STATE));
2777 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs,
2778 eLIM_MLM_WT_DEL_STA_RSP_STATE);
2779 }
2780 if ((eLIM_STA_ROLE ==
2781 GET_LIM_SYSTEM_ROLE(psessionEntry)) ||
2782 (eLIM_BT_AMP_STA_ROLE ==
2783 GET_LIM_SYSTEM_ROLE(psessionEntry))) {
2784 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
2785 psessionEntry->peSessionId,
2786 eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002787
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302788 psessionEntry->limMlmState =
2789 eLIM_MLM_WT_DEL_STA_RSP_STATE;
2790 }
2791
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 }
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302793 /**
2794 * we need to defer the message until we get the
2795 * response back from HAL.
2796 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Abhinav Kumarecb0e3a2018-06-13 14:57:35 +05302798 pDelStaParams->respReqd = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 }
2800
2801 /* Update PE session ID*/
2802 pDelStaParams->sessionId = psessionEntry->peSessionId;
2803
2804 pDelStaParams->status = eHAL_STATUS_SUCCESS;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302805#ifdef SAP_AUTH_OFFLOAD
Agrawal Ashishce4190c2017-01-04 23:41:16 +05302806 if (pMac->sap_auth_offload && LIM_IS_AP_ROLE(psessionEntry))
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302807 msgQ.type = WDA_SAP_OFL_DEL_STA;
2808 else
2809 msgQ.type = WDA_DELETE_STA_REQ;
2810#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 msgQ.type = WDA_DELETE_STA_REQ;
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05302812#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 msgQ.reserved = 0;
2814 msgQ.bodyptr = pDelStaParams;
2815 msgQ.bodyval = 0;
2816
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302817 limLog( pMac, LOG1, FL( "Sessionid %d :Sending SIR_HAL_DELETE_STA_REQ "
2818 "for STAID: %X and AssocID: %d MAC : "MAC_ADDRESS_STR ),
2819 pDelStaParams->sessionId,
2820 pDelStaParams->staIdx, pDelStaParams->assocId,
2821 MAC_ADDR_ARRAY(pStaDs->staAddr));
2822
Jeff Johnsone7245742012-09-05 17:12:55 -07002823 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2825 if( eSIR_SUCCESS != retCode)
2826 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002827 if(fRespReqd)
2828 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002829 limLog( pMac, LOGE, FL("Posting DELETE_STA_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302831 vos_mem_free(pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 }
2833
2834 return retCode;
2835}
2836
2837#if defined WLAN_FEATURE_VOWIFI_11R
2838/*------------------------------------------------------------------------
2839 * limAddFTStaSelf()
2840 *
2841 * FUNCTION:
2842 *
2843 * This function is called to add a STA once we have connected with a new
2844 * AP, that we have performed an FT to.
2845 *
2846 * The Add STA Response is created and now after the ADD Bss Is Successful
2847 * we add the self sta. We update with the association id from the reassoc
2848 * response from the AP.
2849 *------------------------------------------------------------------------
2850 */
2851tSirRetStatus limAddFTStaSelf(tpAniSirGlobal pMac, tANI_U16 assocId, tpPESession psessionEntry)
2852{
2853 tpAddStaParams pAddStaParams = NULL;
2854 tSirMsgQ msgQ;
2855 tSirRetStatus retCode = eSIR_SUCCESS;
2856
2857 pAddStaParams = pMac->ft.ftPEContext.pAddStaReq;
2858 pAddStaParams->assocId = assocId;
2859
2860 msgQ.type = SIR_HAL_ADD_STA_REQ;
2861 msgQ.reserved = 0;
2862 msgQ.bodyptr = pAddStaParams;
2863 msgQ.bodyval = 0;
2864
2865
2866#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002867 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ), pAddStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002868#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002869 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002870
2871 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002872 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2874 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2875 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002876 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302877 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 }
2879 //
2880 // Dont need it any more
2881 pMac->ft.ftPEContext.pAddStaReq = NULL;
2882 return retCode;
2883}
2884
2885#endif /* WLAN_FEATURE_VOWIFI_11R */
2886
2887/**
2888 * limAddStaSelf()
2889 *
2890 *FUNCTION:
2891 * This function is called to add an STA context at hardware
2892 * whenever a STA is (Re) Associated.
2893 *
2894 *LOGIC:
2895 *
2896 *ASSUMPTIONS:
2897 * NA
2898 *
2899 *NOTE:
2900 * NA
2901 *
2902 * @param pMac - Pointer to Global MAC structure
2903 * @param pStaDs - Pointer to the STA datastructure created by
2904 * LIM and maintained by DPH
2905 * @return retCode - Indicates success or failure return code
2906 */
2907
2908tSirRetStatus
2909limAddStaSelf(tpAniSirGlobal pMac,tANI_U16 staIdx, tANI_U8 updateSta, tpPESession psessionEntry)
2910{
2911 tpAddStaParams pAddStaParams = NULL;
2912 tSirMsgQ msgQ;
2913 tSirRetStatus retCode = eSIR_SUCCESS;
2914 tSirMacAddr staMac;
2915 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
krunal soni71343fb2013-09-16 16:16:26 -07002916 tANI_U32 shortGi20MhzSupport;
2917 tANI_U32 shortGi40MhzSupport;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302918 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002919 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2920 * that cfg carries the systemwide capability that device under
2921 * consideration can support. This capability gets plumbed into the cfg
2922 * cache at system initialization time via the .dat and .ini file override
2923 * mechanisms and will not change. If it does change, it is the
2924 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2925 * command.*/
2926 tANI_U32 selfStaDot11Mode=0, selfTxWidth=0;
2927 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
2928 limLog( pMac, LOG1, FL("cfgDot11Mode %d"),(int)selfStaDot11Mode);
2929 wlan_cfgGetInt(pMac,WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,&selfTxWidth);
2930 limLog( pMac, LOG1, FL("SGI 20 %d"),(int)selfTxWidth);
2931 limLog( pMac, LOG1, FL("Roam Channel Bonding Mode %d"),(int)pMac->roam.configParam.uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002932
2933 #if 0
2934 retCode =wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2935 if (retCode != eSIR_SUCCESS)
2936 {
2937 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002938 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 return retCode;
2940 }
2941 #endif //TO SUPPORT BT-AMP
2942 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302943 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": "),MAC_ADDR_ARRAY(staMac));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302944 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2945 if (NULL == pAddStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302947 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 return eSIR_MEM_ALLOC_FAILED;
2949 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302950 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002951
2952 /// Add STA context at MAC HW (BMU, RHP & TFP)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302953 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2954 (tANI_U8 *) staMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002955
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302956 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2957 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002958
2959 pAddStaParams->assocId = psessionEntry->limAID;
2960 pAddStaParams->staType = STA_ENTRY_SELF;
2961 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2962 pAddStaParams->respReqd = 1;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302963 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 /* Update PE session ID */
2965 pAddStaParams->sessionId = psessionEntry->peSessionId;
2966
2967 // This will indicate HAL to "allocate" a new STA index
2968 pAddStaParams->staIdx = staIdx;
2969 pAddStaParams->updateSta = updateSta;
2970
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302971 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
2972 {
2973 limLog(pMac, LOGP, FL("Get short preamble failed. Set Default value"));
2974 pAddStaParams->shortPreambleSupported = 1;
2975 }
2976 pAddStaParams->shortPreambleSupported = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002977
Jeff Johnsone7245742012-09-05 17:12:55 -07002978#ifdef WLAN_FEATURE_11AC
2979 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry,NULL);
2980#else
2981 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
2982#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002983// if( psessionEntry->htCapability)---> old check
2984 /*We used to check if the session is htCapable before setting the htCapable
2985 * flag. The check limited us from operating */
2986 if ( IS_DOT11_MODE_HT(selfStaDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002988 pAddStaParams->htCapable = TRUE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002989#ifdef DISABLE_GF_FOR_INTEROP
2990 /*
2991 * To resolve the interop problem with Broadcom AP,
2992 * where TQ STA could not pass traffic with GF enabled,
2993 * TQ STA will do Greenfield only with TQ AP, for
2994 * everybody else it will be turned off.
2995 */
2996 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2997 {
2998 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2999 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
3000 }
3001 else
3002#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003003 {
3004 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
3005 pAddStaParams->txChannelWidthSet =
3006 pMac->roam.configParam.channelBondingMode5GHz;
3007 // pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
3008 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
3009 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
3010 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
3011 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
3012 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
3013 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
3014 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
3015 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
krunal soni71343fb2013-09-16 16:16:26 -07003016 /*
3017 * We will read the gShortGI20Mhz from ini file, and if it is set
3018 * to 1 then we will tell Peer that we support 40Mhz short GI
3019 */
3020 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3021 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3022 &shortGi20MhzSupport)))
3023 {
3024 if (VOS_TRUE == shortGi20MhzSupport)
3025 {
3026 pAddStaParams->fShortGI20Mhz =
3027 WNI_CFG_SHORT_GI_20MHZ_STAMAX;
3028 //pAddStaParams->fShortGI20Mhz =
3029 //limGetHTCapability(pMac, eHT_SHORT_GI_20MHZ,
3030 // psessionEntry);
3031 }
3032 else
3033 {
3034 pAddStaParams->fShortGI20Mhz = VOS_FALSE;
3035 }
3036 }
3037 else
3038 {
3039 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3040 "CFG,setting value to default"));)
3041 pAddStaParams->fShortGI20Mhz = WNI_CFG_SHORT_GI_20MHZ_STADEF;
3042 }
3043
3044 /*
3045 * We will read the gShortGI40Mhz from ini file, and if it is set
3046 * to 1 then we will tell Peer that we support 40Mhz short GI
3047 */
3048 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3049 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3050 &shortGi40MhzSupport)))
3051 {
3052 if (VOS_TRUE == shortGi40MhzSupport)
3053 {
3054 pAddStaParams->fShortGI40Mhz =
3055 WNI_CFG_SHORT_GI_40MHZ_STAMAX;
3056 //pAddStaParams->fShortGI40Mhz =
3057 //limGetHTCapability(pMac, eHT_SHORT_GI_40MHZ,
3058 // psessionEntry);
3059 }
3060 else
3061 {
3062 pAddStaParams->fShortGI40Mhz = VOS_FALSE;
3063 }
3064 }
3065 else
3066 {
3067 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3068 "CFG,setting value to default"));)
3069 pAddStaParams->fShortGI40Mhz = WNI_CFG_SHORT_GI_40MHZ_STADEF;
3070 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303071 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303072 "maxAmpduSize = %d"), pAddStaParams->greenFieldCapable,
3073 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
3074
Abhishek Singh525045c2014-12-15 17:18:45 +05303075 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303076 "fShortGI40Mhz: %d lsigTxopProtection: %d"),
3077 pAddStaParams->fDsssCckMode40Mhz, pAddStaParams->fShortGI20Mhz,
3078 pAddStaParams->fShortGI40Mhz, pAddStaParams->lsigTxopProtection);
3079
Abhishek Singh525045c2014-12-15 17:18:45 +05303080 limLog(pMac, LOG1, FL(" maxAmsduSize: %d txChannelWidthSet: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303081 "mimoPS: %d rifsMode %d delBASupport %d"),
3082 pAddStaParams->maxAmsduSize,
3083 pAddStaParams->txChannelWidthSet, pAddStaParams->mimoPS,
3084 pAddStaParams->rifsMode, pAddStaParams->delBASupport );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003087#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003088 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
3089 if (pAddStaParams->vhtCapable){
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003090 pAddStaParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003091 limLog( pMac, LOG1, FL("VHT WIDTH SET %d"),pAddStaParams->vhtTxChannelWidthSet);
3092 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08003093 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Abhishek Singh525045c2014-12-15 17:18:45 +05303094 limLog(pMac, LOG1, FL("vhtCapable: %d vhtTxBFCapable %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303095 pAddStaParams->vhtCapable, pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003096#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003097
3098 /* For Self STA get the LDPC capability from session i.e config.ini*/
3099 pAddStaParams->htLdpcCapable =
3100 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
3101 pAddStaParams->vhtLdpcCapable =
3102 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
3103
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003105 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
3107
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3109 {
3110 pAddStaParams->p2pCapableSta = 1;
3111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003112
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003113 //limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
3114 pAddStaParams->supportedRates.opRateMode = limGetStaRateMode((tANI_U8)selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003115
Abhishek Singh525045c2014-12-15 17:18:45 +05303116 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303117 pAddStaParams->staIdx,pAddStaParams->updateSta,
3118 pAddStaParams->htCapable);
3119
Abhishek Singh525045c2014-12-15 17:18:45 +05303120 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303121 "p2pCapableSta: %d"),
3122 pAddStaParams->htLdpcCapable,pAddStaParams->vhtLdpcCapable,
3123 pAddStaParams->p2pCapableSta);
3124
Abhishek Singh525045c2014-12-15 17:18:45 +05303125 limLog(pMac, LOG1, FL(" sessionid: %d Assoc ID: %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303126 " shortPreambleSupported: %d "), psessionEntry->smeSessionId,
3127 pAddStaParams->assocId, pAddStaParams->listenInterval,
3128 pAddStaParams->shortPreambleSupported);
3129
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 msgQ.type = WDA_ADD_STA_REQ;
3131 //
3132 // FIXME_GEN4
3133 // A global counter (dialog token) is required to keep track of
3134 // all PE <-> HAL communication(s)
3135 //
3136 msgQ.reserved = 0;
3137 msgQ.bodyptr = pAddStaParams;
3138 msgQ.bodyval = 0;
3139
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303140 limLog( pMac, LOGW, FL(MAC_ADDRESS_STR":Sessionid %d : "
3141 "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ),
3142 MAC_ADDR_ARRAY(pAddStaParams->staMac),
3143 pAddStaParams->sessionId,
3144 pAddStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07003145 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003146
3147 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3148 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003149 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303150 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 }
3152 return retCode;
3153}
3154
3155
3156/**
3157 * limTeardownInfraBSS()
3158 *
3159 *FUNCTION:
3160 * This function is called by various LIM functions to teardown
3161 * an established Infrastructure BSS
3162 *
3163 *LOGIC:
3164 *
3165 *ASSUMPTIONS:
3166 *
3167 *NOTE:
3168 *
3169 * @param pMac - Pointer to Global MAC structure
3170 * @return None
3171 */
3172
3173void
3174limTeardownInfraBss(tpAniSirGlobal pMac,tpPESession psessionEntry)
3175{
3176 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3177
3178 /**
3179 * Send Broadcast Disassociate frame with
3180 * 'leaving BSS' reason.
3181 */
3182 limSendDisassocMgmtFrame(pMac,
3183 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003184 bcAddr,psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003185} /*** end limTeardownInfraBss() ***/
3186
3187
3188/**
3189 * limHandleCnfWaitTimeout()
3190 *
3191 *FUNCTION:
3192 * This function is called by limProcessMessageQueue to handle
3193 * various confirmation failure cases.
3194 *
3195 *LOGIC:
3196 *
3197 *ASSUMPTIONS:
3198 *
3199 *NOTE:
3200 *
3201 * @param pMac - Pointer to Global MAC structure
3202 * @param pStaDs - Pointer to a sta descriptor
3203 * @return None
3204 */
3205
3206void limHandleCnfWaitTimeout(tpAniSirGlobal pMac, tANI_U16 staId)
3207{
3208 tpDphHashNode pStaDs;
3209 tLimSystemRole systemRole;
3210 tpPESession psessionEntry = NULL;
3211
3212 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId))== NULL)
3213 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003214 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 return;
3216 }
3217 systemRole = limGetSystemRole(psessionEntry);
3218 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
3219
3220 if (pStaDs == NULL)
3221 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003222 PELOGW(limLog(pMac, LOGW, FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 return;
3224 }
3225
3226 switch (pStaDs->mlmStaContext.mlmState) {
3227 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003228 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 -07003229 limPrintMacAddr(pMac, pStaDs->staAddr, LOGW);
3230
3231 if ( (systemRole == eLIM_AP_ROLE)|| (systemRole == eLIM_BT_AMP_AP_ROLE) )
3232 {
3233 limRejectAssociation(
3234 pMac,
3235 pStaDs->staAddr,
3236 pStaDs->mlmStaContext.subType,
3237 true,
3238 pStaDs->mlmStaContext.authType,
3239 pStaDs->assocId,
3240 true,
3241 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
3242 psessionEntry);
3243 }
3244 break;
3245
3246 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003247 limLog(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 pStaDs->mlmStaContext.mlmState);
3249 }
3250}
3251
3252
3253/**
3254 * limDeleteDphHashEntry()
3255 *
3256 *FUNCTION:
3257 * This function is called whenever we need to delete
3258 * the dph hash entry
3259 *
3260 *LOGIC:
3261 *
3262 *ASSUMPTIONS:
3263 *
3264 *NOTE:
3265 *
3266 * @param pMac Pointer to Global MAC structure
3267 * @param tANI_U16 staId
3268 * @return None
3269 */
3270
3271void
3272limDeleteDphHashEntry(tpAniSirGlobal pMac, tSirMacAddr staAddr, tANI_U16 staId,tpPESession psessionEntry)
3273{
3274 tANI_U16 aid;
3275 tpDphHashNode pStaDs;
3276 tUpdateBeaconParams beaconParams;
3277 tLimSystemRole systemRole;
3278
Kaushik, Sushantfb156732014-01-07 15:36:03 +05303279 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 beaconParams.paramChangeBitmap = 0;
3281 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, staId);
3282 if (NULL == psessionEntry)
3283 {
3284 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
3285 return;
3286 }
3287 systemRole = limGetSystemRole(psessionEntry);
3288 beaconParams.bssIdx = psessionEntry->bssIdx;
3289 pStaDs = dphLookupHashEntry(pMac, staAddr, &aid, &psessionEntry->dph.dphHashTable);
3290 if (pStaDs != NULL)
3291 {
3292 PELOGW(limLog(pMac, LOGW, FL("Deleting DPH Hash entry for STAID: %X\n "), staId);)
3293 // update the station count and perform associated actions
3294 // do this before deleting the dph hash entry
3295 limUtilCountStaDel(pMac, pStaDs, psessionEntry);
3296
3297 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||
3298 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
3299 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
3301 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE){
3302 limDecideApProtectionOnDelete(pMac, pStaDs, &beaconParams,psessionEntry);
3303 }
3304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003305
3306 if(eLIM_STA_IN_IBSS_ROLE == systemRole)
3307 limIbssDecideProtectionOnDelete(pMac, pStaDs, &beaconParams, psessionEntry);
3308
3309 limDecideShortPreamble(pMac, pStaDs, &beaconParams, psessionEntry);
3310 limDecideShortSlot(pMac, pStaDs, &beaconParams, psessionEntry);
3311
3312 //Send message to HAL about beacon parameter change.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003313 PELOGW(limLog(pMac, LOGW, FL("param bitmap = %d "), beaconParams.paramChangeBitmap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 if(beaconParams.paramChangeBitmap)
3315 {
3316 schSetFixedBeaconFields(pMac,psessionEntry);
3317 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
3318 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08003319
3320#ifdef WLAN_FEATURE_11W
3321 tx_timer_delete(&pStaDs->pmfSaQueryTimer);
3322#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 }
3324 if (dphDeleteHashEntry(pMac, staAddr, staId, &psessionEntry->dph.dphHashTable) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003325 limLog(pMac, LOGP, FL("error deleting hash entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 }
3327}
3328
3329
3330
3331/**
3332 * limCheckAndAnnounceJoinSuccess()
3333 *
3334 *FUNCTION:
3335 * This function is called upon receiving Beacon/Probe Response
3336 * frame in WT_JOIN_BEACON_STATE to check if the received
3337 * Beacon/Probe Response is from the BSS that we're attempting
3338 * to join.
3339 *
3340 *LOGIC:
3341 * If the Beacon/Probe Response is indeed from the BSS we're
3342 * attempting to join, join success is sent to SME.
3343 *
3344 *ASSUMPTIONS:
3345 *
3346 *NOTE:
3347 *
3348 * @param pMac Pointer to Global MAC structure
3349 * @param pBPR Pointer to received Beacon/Probe Response
3350 * @param pHdr Pointer to received Beacon/Probe Response
3351 * MAC header
3352 * @return None
3353 */
3354
3355void
3356limCheckAndAnnounceJoinSuccess(tpAniSirGlobal pMac,
3357 tSirProbeRespBeacon *pBPR,
3358 tpSirMacMgmtHdr pHdr,tpPESession psessionEntry)
3359{
3360 tSirMacSSid currentSSID;
3361 tLimMlmJoinCnf mlmJoinCnf;
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003362 tANI_U32 val = 0;
3363 tANI_U32 *noa1DurationFromBcn = NULL;
3364 tANI_U32 *noa2DurationFromBcn = NULL;
3365 tANI_U32 noa;
3366 tANI_U32 TotalNum_NoADesc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003367
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303368 vos_mem_copy(currentSSID.ssId,
3369 psessionEntry->ssId.ssId,
3370 psessionEntry->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003371
3372 currentSSID.length = (tANI_U8)psessionEntry->ssId.length ;
3373
3374 if (
3375 /* Check for SSID only in probe response. Beacons may not carry
3376 SSID information in hidden SSID case */
3377 ( (SIR_MAC_MGMT_FRAME == pHdr->fc.type) &&
3378 (SIR_MAC_MGMT_PROBE_RSP == pHdr->fc.subType) ) &&
3379 currentSSID.length &&
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303380 (!vos_mem_compare((tANI_U8 *) &pBPR->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 (tANI_U8 *) &currentSSID,
3382 (tANI_U8) (1 + currentSSID.length)) ))
3383 {
3384 /**
3385 * Received SSID does not match with the one we've.
3386 * Ignore received Beacon frame
3387 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303388 limLog(pMac, LOG1, FL("SSID received in Beacon does not match"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003389#ifdef WLAN_DEBUG
3390 pMac->lim.gLimBcnSSIDMismatchCnt++;
3391#endif
3392 return;
3393 }
3394
3395 if( (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_STA_ROLE))
3396 {
Nirav Shahbc35fb72013-12-12 18:14:06 +05303397 limLog(pMac, LOG1, FL("Received Beacon/PR with matching BSSID"
3398 MAC_ADDRESS_STR "PESessionID %d"),
3399 MAC_ADDR_ARRAY(psessionEntry->bssId),
3400 psessionEntry->peSessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 // Deactivate Join Failure timer
3402 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003403 // Deactivate Periodic Join timer
3404 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07003405
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003406 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona &&
3407 pBPR->P2PProbeRes.NoticeOfAbsence.present)
3408 {
3409
3410 noa1DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3411
3412 if(pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3413 TotalNum_NoADesc = pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc/SIZE_OF_NOA_DESCRIPTOR;
3414
3415 noa = *noa1DurationFromBcn;
3416
3417 if(TotalNum_NoADesc > 1)
3418 {
3419 noa2DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + SIZE_OF_NOA_DESCRIPTOR + 1);
3420 noa += *noa2DurationFromBcn;
3421 }
3422
3423 /*If MAX Noa exceeds 3 secs we will consider only 3 secs to
3424 * avoid arbitary values in noa duration field
3425 */
3426 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ? MAX_NOA_PERIOD_IN_MICROSECS : noa;
3427 noa = noa/1000; //Convert to ms
3428
3429 if( wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,&val) == eSIR_SUCCESS )
3430 {
3431 psessionEntry->defaultAuthFailureTimeout = val;
3432 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,val + noa, NULL, eANI_BOOLEAN_FALSE);
3433 }
3434 }
3435 else
3436 {
3437 psessionEntry->defaultAuthFailureTimeout = 0;
3438 }
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 // Update Beacon Interval at CFG database
3441
3442 if ( pBPR->HTCaps.present )
3443 limUpdateStaRunTimeHTCapability( pMac, &pBPR->HTCaps );
3444 if ( pBPR->HTInfo.present )
3445 limUpdateStaRunTimeHTInfo( pMac, &pBPR->HTInfo, psessionEntry);
3446 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003447 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003448
Ganesh Kondabattiniaad38d92014-11-19 17:06:00 +05303449 /* update the capability info based on recently
3450 * received beacon/probe response frame */
3451 psessionEntry->limCurrentBssCaps = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003452
3453 /**
3454 * Announce join success by sending
3455 * Join confirm to SME.
3456 */
3457 mlmJoinCnf.resultCode = eSIR_SME_SUCCESS;
3458 mlmJoinCnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3459 /* Update PE sessionId*/
3460 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3461 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3462 } // if ((pMac->lim.gLimSystemRole == IBSS....
Abhishek Singh74037df2017-07-20 11:08:56 +05303463
3464 /* Update HS 2.0 Information Element */
3465 sir_copy_hs20_ie(&psessionEntry->hs20vendor_ie, &pBPR->hs20vendor_ie);
Jeff Johnson295189b2012-06-20 16:38:30 -07003466}
3467
3468/**
3469 * limExtractApCapabilities()
3470 *
3471 *FUNCTION:
3472 * This function is called to extract all of the AP's capabilities
3473 * from the IEs received from it in Beacon/Probe Response frames
3474 *
3475 *LOGIC:
3476 * This routine mimics the limExtractApCapability() API. The difference here
3477 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3478 * left to the caller of this API to use this info as required
3479 *
3480 *ASSUMPTIONS:
3481 * NA
3482 *
3483 *NOTE:
3484 *
3485 * @param pMac Pointer to Global MAC structure
3486 * @param pIE Pointer to starting IE in Beacon/Probe Response
3487 * @param ieLen Length of all IEs combined
3488 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3489 * populated
3490 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3491 */
3492tSirRetStatus limExtractApCapabilities( tpAniSirGlobal pMac,
3493 tANI_U8 *pIE,
3494 tANI_U16 ieLen,
3495 tpSirProbeRespBeacon beaconStruct )
3496{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303497 vos_mem_set((tANI_U8 *) beaconStruct, sizeof( tSirProbeRespBeacon ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498
3499 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003500 FL( "In limExtractApCapabilities: The IE's being received are:" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
3502
3503 // Parse the Beacon IE's, Don't try to parse if we dont have anything in IE
3504 if (ieLen > 0) {
3505 if( eSIR_SUCCESS != sirParseBeaconIE( pMac, beaconStruct, pIE, (tANI_U32)ieLen ))
3506 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003507 limLog( pMac, LOGE, FL("APCapExtract: Beacon parsing error!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 return eSIR_FAILURE;
3509 }
3510 }
3511
3512 return eSIR_SUCCESS;
3513}
3514
3515
3516/**
3517 * limDelBss()
3518 *
3519 *FUNCTION:
3520 * This function is called to delete BSS context at hardware
3521 * whenever a STA is disassociated
3522 *
3523 *LOGIC:
3524 *
3525 *ASSUMPTIONS:
3526 * NA
3527 *
3528 *NOTE:
3529 * NA
3530 *
3531 * @param pMac - Pointer to Global MAC structure
3532 * @param pStaDs - Pointer to the STA datastructure created by
3533 * LIM and maintained by DPH
3534 * @return retCode - Indicates success or failure return code
3535 */
3536
3537tSirRetStatus
3538limDelBss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tANI_U16 bssIdx,tpPESession psessionEntry)
3539{
3540 tpDeleteBssParams pDelBssParams = NULL;
3541 tSirMsgQ msgQ;
3542 tSirRetStatus retCode = eSIR_SUCCESS;
3543
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303544 pDelBssParams = vos_mem_malloc(sizeof(tDeleteBssParams));
3545 if (NULL == pDelBssParams)
3546 {
3547 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 return eSIR_MEM_ALLOC_FAILED;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303549 }
3550 vos_mem_set((tANI_U8 *) pDelBssParams, sizeof(tDeleteBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003551
3552
3553 pDelBssParams->sessionId = psessionEntry->peSessionId; //update PE session Id
3554
3555 //DPH was storing the AssocID in staID field,
3556 //staID is actually assigned by HAL when AddSTA message is sent.
3557 if (pStaDs != NULL)
3558 {
3559 pDelBssParams->bssIdx= pStaDs->bssId;
3560 pStaDs->valid = 0;
3561 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3562 }
3563 else
3564 pDelBssParams->bssIdx = bssIdx;
3565 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003566 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003567
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07003568 if((psessionEntry->peSessionId == pMac->lim.limTimers.gLimJoinFailureTimer.sessionId) &&
3569 (VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)))
3570 {
3571 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
3572 }
3573
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 pDelBssParams->status= eHAL_STATUS_SUCCESS;
3575 pDelBssParams->respReqd = 1;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303576
3577 PELOGW(limLog( pMac, LOGW, FL("Sessionid %d : Sending HAL_DELETE_BSS_REQ "
3578 "for bss idx: %X BSSID:"MAC_ADDRESS_STR), pDelBssParams->sessionId,
3579 pDelBssParams->bssIdx,
3580 MAC_ADDR_ARRAY(psessionEntry->bssId));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003581
3582 //we need to defer the message until we get the response back from HAL.
3583 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3584
3585 msgQ.type = WDA_DELETE_BSS_REQ;
3586 msgQ.reserved = 0;
3587 msgQ.bodyptr = pDelBssParams;
3588 msgQ.bodyval = 0;
3589
Jeff Johnsone7245742012-09-05 17:12:55 -07003590 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003591
3592 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3593 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003594 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003595 limLog( pMac, LOGE, FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303596 vos_mem_free(pDelBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 }
3598
3599 return retCode;
3600}
3601
3602
Jeff Johnson295189b2012-06-20 16:38:30 -07003603
3604/**
3605 * limSendAddBss()
3606 *
3607 *FUNCTION:
3608 *
3609 *LOGIC:
3610 * 1) LIM receives eWNI_SME_JOIN_REQ
3611 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3612 * SIR_HAL_ADD_BSS_REQ to HAL
3613 *
3614 *ASSUMPTIONS:
3615 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3616 * ADD BSS parameters can be obtained from two sources:
3617 * 1) pMac->lim.gLimMlmJoinReq
3618 * 2) beaconStruct, passed as paramter
3619 * So, if a reqd parameter is found in bssDescriptions
3620 * then it is given preference over beaconStruct
3621 *
3622 *NOTE:
3623 *
3624 * @param pMac Pointer to Global MAC structure
3625 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3626 * beaconstruct Has the ProbeRsp/Beacon structured details
3627 * bssDescription bssDescription passed to PE from the SME
3628 * @return None
3629 */
3630
3631tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3632 tpSchBeaconStruct pBeaconStruct, tpSirBssDescription bssDescription, tANI_U8 updateEntry,
3633 tpPESession psessionEntry)
3634
3635{
3636 tSirMsgQ msgQ;
3637 tpAddBssParams pAddBssParams = NULL;
3638 tANI_U32 retCode;
3639 tANI_U8 i;
3640 tpDphHashNode pStaDs = NULL;
3641 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003642 tANI_U32 shortGi20MhzSupport;
3643 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303645 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
3646 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 {
3648 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303649 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 retCode = eSIR_MEM_ALLOC_FAILED;
3651 goto returnFailure;
3652 }
3653 else
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303654 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303656 vos_mem_copy(pAddBssParams->bssId,bssDescription->bssId,
3657 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303659 vos_mem_copy(pAddBssParams->selfMacAddr,
3660 psessionEntry->selfMacAddr,
3661 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303662
3663 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
3664 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
3665
3666 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
3667 MAC_ADDR_ARRAY(pAddBssParams->bssId));
3668
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3670 {
3671 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3672 }
3673 else
3674 {
3675 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3676 }
3677
3678 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3679
3680 /* Update PE session ID */
3681 pAddBssParams->sessionId = psessionEntry->peSessionId;
3682
3683 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3684
3685 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3686 pAddBssParams->updateBss = updateEntry;
3687
3688
3689 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3690 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3691 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3692 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
3693
3694 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303695 vos_mem_copy(pAddBssParams->rateSet.rate,
3696 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003697
3698 pAddBssParams->nwType = bssDescription->nwType;
3699
Jeff Johnsone7245742012-09-05 17:12:55 -07003700 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3702 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3703 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3704 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3705
Abhishek Singh525045c2014-12-15 17:18:45 +05303706 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303707 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
3708 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
3709
Abhishek Singh525045c2014-12-15 17:18:45 +05303710 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303711 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
3712 pAddBssParams->cfParamSet.cfpMaxDuration,
3713 pAddBssParams->cfParamSet.cfpDurRemaining,
3714 pAddBssParams->rateSet.numRates);
3715
Abhishek Singh525045c2014-12-15 17:18:45 +05303716 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303717 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
3718 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
3719 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
3720 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07003721
3722 // Use the advertised capabilities from the received beacon/PR
3723
3724
3725 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3726 {
3727 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05303728 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 if ( pBeaconStruct->HTInfo.present )
3730 {
3731 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pAssocRsp->HTInfo.opMode;
3732 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pAssocRsp->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3735 (chanWidthSupp) )
3736 {
3737 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3738 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3739 }
3740 else
3741 {
3742 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003743 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 }
3745 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3746 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3747 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303748
Abhishek Singh525045c2014-12-15 17:18:45 +05303749 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303750 "txChannelWidthSet: %d currentExtChannel: %d "),
3751 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
3752 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
3753
Abhishek Singh525045c2014-12-15 17:18:45 +05303754 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303755 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
3756 pAddBssParams->llnNonGFCoexist,
3757 pAddBssParams->fLsigTXOPProtectionFullSupport,
3758 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 }
3760 }
3761
3762 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05303763 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303764 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003765#ifdef WLAN_FEATURE_11AC
3766 if (psessionEntry->vhtCapability && ( pAssocRsp->VHTCaps.present ))
3767 {
3768 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3769 pAddBssParams->vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth;
3770 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003771 pAddBssParams->currentOperChannel,
3772 pAddBssParams->currentExtChannel,
3773 psessionEntry->apCenterChan,
3774 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003775 }
3776 else
3777 {
3778 pAddBssParams->vhtCapable = 0;
3779 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303780 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303781 "currentExtChannel %d"),pAddBssParams->vhtCapable,
3782 pAddBssParams->vhtTxChannelWidthSet,
3783 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003784#endif
3785
3786
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 // Populate the STA-related parameters here
3788 // Note that the STA here refers to the AP
3789 {
3790 /* staType = PEER*/
3791 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3792
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303793 vos_mem_copy(pAddBssParams->staContext.bssId,
3794 bssDescription->bssId,
3795 sizeof( tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3797
3798 /* Fill Assoc id from the dph table */
3799 pStaDs = dphLookupHashEntry(pMac, pAddBssParams->staContext.bssId,
3800 &pAddBssParams->staContext.assocId, &psessionEntry->dph.dphHashTable);
3801 if (pStaDs == NULL)
3802 {
Arif Hussain24bafea2013-11-15 15:10:03 -08003803 PELOGE(limLog(pMac, LOGE, FL("Couldn't get assoc id for "
3804 "MAC ADDR: " MAC_ADDRESS_STR),
3805 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 }
3807 pAddBssParams->staContext.uAPSD = 0;
3808 pAddBssParams->staContext.maxSPLen = 0;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05303809 pAddBssParams->staContext.shortPreambleSupported =
3810 psessionEntry->beaconParams.fShortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 pAddBssParams->staContext.updateSta = updateEntry;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303812
Abhishek Singh525045c2014-12-15 17:18:45 +05303813 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303814 " shortPreambleSupported: %d"),
3815 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
3816 pAddBssParams->staContext.shortPreambleSupported);
3817
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003818 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 {
3820 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3821 pAddBssParams->staContext.htCapable = 1;
3822 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3823 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05303824 limLog(pMac, LOG1,FL("StaContext htCapable: %d greenFieldCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303825 "lsigTxopProtection: %d"), pAddBssParams->staContext.htCapable,
3826 pAddBssParams->staContext.greenFieldCapable,
3827 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003828#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05303829 if (psessionEntry->vhtCapability &&
3830 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003831 {
3832 pAddBssParams->staContext.vhtCapable = 1;
3833 if ((pAssocRsp->VHTCaps.suBeamFormerCap ||
3834 pAssocRsp->VHTCaps.muBeamformerCap) &&
3835 psessionEntry->txBFIniFeatureEnabled)
3836 {
3837 pAddBssParams->staContext.vhtTxBFCapable = 1;
3838 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303839 if (pAssocRsp->VHTCaps.muBeamformerCap &&
3840 psessionEntry->txMuBformee )
3841 {
3842 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
3843 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
3844 /* Dont allow any other MuBf session as concurrency
3845 * is not supported
3846 */
3847 pMac->isMuBfsessionexist = TRUE;
3848 }
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003849 }
3850#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3852 (chanWidthSupp) )
3853 {
3854 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003855#ifdef WLAN_FEATURE_11AC
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003856 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003857 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003858 pAddBssParams->staContext.vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth; //pMac->lim.apChanWidth;
3859 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303860 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303861 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
3862 pAddBssParams->staContext.vhtCapable,
3863 pAddBssParams->staContext.vhtTxChannelWidthSet,
3864 pAddBssParams->staContext.vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003865#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003866 }
3867 else
3868 {
3869 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3870 }
3871 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pAssocRsp->HTCaps.mimoPowerSave;
3872 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3873 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3874 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3875 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003876 /*
3877 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3878 * if they are set then we will use what ever Assoc response coming
3879 * from AP supports. If these values are set as 0 in ini file then
3880 * we will hardcode this values to 0.
3881 */
3882 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3883 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3884 &shortGi20MhzSupport)))
3885 {
3886 if (VOS_TRUE == shortGi20MhzSupport)
3887 {
3888 pAddBssParams->staContext.fShortGI20Mhz =
3889 (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3890 }
3891 else
3892 {
3893 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3894 }
3895 }
3896 else
3897 {
3898 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3899 "CFG,setting value to default"));)
3900 pAddBssParams->staContext.fShortGI20Mhz =
3901 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3902 }
3903
3904 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3905 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3906 &shortGi40MhzSupport)))
3907 {
3908 if (VOS_TRUE == shortGi40MhzSupport)
3909 {
3910 pAddBssParams->staContext.fShortGI40Mhz =
3911 (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3912 }
3913 else
3914 {
3915 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3916 }
3917 }
3918 else
3919 {
3920 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3921 "CFG,setting value to default"));)
3922 pAddBssParams->staContext.fShortGI40Mhz =
3923 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3924 }
3925
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05303927 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003928 {
3929 pAddBssParams->staContext.htLdpcCapable = 0;
3930 pAddBssParams->staContext.vhtLdpcCapable = 0;
3931 }
3932 else
3933 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05303934 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
3935 pAddBssParams->staContext.htLdpcCapable =
3936 (tANI_U8)pAssocRsp->HTCaps.advCodingCap;
3937 else
3938 pAddBssParams->staContext.htLdpcCapable = 0;
3939 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
3940 pAddBssParams->staContext.vhtLdpcCapable =
3941 (tANI_U8)pAssocRsp->VHTCaps.ldpcCodingCap;
3942 else
3943 pAddBssParams->staContext.vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003944 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003945
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 if( pBeaconStruct->HTInfo.present )
3947 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303948
Abhishek Singh525045c2014-12-15 17:18:45 +05303949 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303950 " delBASupport: %d maxAmsduSize: %d"),
3951 pAddBssParams->staContext.txChannelWidthSet,
3952 pAddBssParams->staContext.mimoPS,
3953 pAddBssParams->staContext.delBASupport,
3954 pAddBssParams->staContext.maxAmsduSize);
3955
Abhishek Singh525045c2014-12-15 17:18:45 +05303956 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303957 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
3958 pAddBssParams->staContext.fDsssCckMode40Mhz,
3959 pAddBssParams->staContext.fShortGI20Mhz);
3960
Abhishek Singh525045c2014-12-15 17:18:45 +05303961 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303962 "htLdpcCapable: %d vhtLdpcCapable: %d"),
3963 pAddBssParams->staContext.fShortGI40Mhz,
3964 pAddBssParams->staContext.maxAmpduSize,
3965 pAddBssParams->staContext.htLdpcCapable,
3966 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 }
3968
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303969 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3970 if ((psessionEntry->limWmeEnabled && (pAssocRsp->wmeEdcaPresent || pAddBssParams->htCapable)) ||
3971 (psessionEntry->limQosEnabled && (pAssocRsp->edcaPresent || pAddBssParams->htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 pAddBssParams->staContext.wmmEnabled = 1;
3973 else
3974 pAddBssParams->staContext.wmmEnabled = 0;
3975
3976 //Update the rates
3977
3978 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3979 if (pStaDs != NULL)
3980 {
3981 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303982 vos_mem_copy((tANI_U8*)&pAddBssParams->staContext.supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 (tANI_U8*)&pStaDs->supportedRates,
3984 sizeof(tSirSupportedRates));
3985 }
3986 else
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003987 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003988
3989 }
3990
3991 //Disable BA. It will be set as part of ADDBA negotiation.
3992 for( i = 0; i < STACFG_MAX_TC; i++ )
3993 {
3994 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3995 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3996 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3997 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3998 }
3999
4000 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4001
4002#if defined WLAN_FEATURE_VOWIFI
4003 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05304004 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304005 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07004006#endif
4007 // FIXME_GEN4 - Any other value that can be used for initialization?
4008 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4009 pAddBssParams->respReqd = true;
4010
4011 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4012
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
4014 {
4015 pAddBssParams->staContext.p2pCapableSta = 1;
4016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004017
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004018 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019
4020#if defined WLAN_FEATURE_VOWIFI_11R
4021 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05304022 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304023 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004024#endif
4025
Chet Lanctot186b5732013-03-18 10:26:30 -07004026#ifdef WLAN_FEATURE_11W
4027 if (psessionEntry->limRmfEnabled)
4028 {
4029 pAddBssParams->rmfEnabled = 1;
4030 pAddBssParams->staContext.rmfEnabled = 1;
4031 }
4032#endif
4033
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 // Set a new state for MLME
4035 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
4036 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
4037 else
4038 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Abhishek Singh2fefebd2016-01-13 14:37:49 +05304039
Jeff Johnsone7245742012-09-05 17:12:55 -07004040 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004041
Abhishek Singh525045c2014-12-15 17:18:45 +05304042 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304043 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
4044 pAddBssParams->staContext.encryptType,
4045 pAddBssParams->staContext.p2pCapableSta);
4046
Abhishek Singh525045c2014-12-15 17:18:45 +05304047 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304048 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
4049 pAddBssParams->halPersona, psessionEntry->limMlmState);
4050
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 //we need to defer the message until we get the response back from HAL.
4052 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4053
4054 msgQ.type = WDA_ADD_BSS_REQ;
4055 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4056 msgQ.reserved = 0;
4057 msgQ.bodyptr = pAddBssParams;
4058 msgQ.bodyval = 0;
4059
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05304060 limLog( pMac, LOG1, FL("SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
4061 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004062 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004063
4064 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4065 if( eSIR_SUCCESS != retCode)
4066 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004067 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304068 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004069 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 retCode );
4071 goto returnFailure;
4072
4073 }
4074 else
4075 return retCode;
4076
4077 returnFailure:
4078 // Clean-up will be done by the caller...
4079 return retCode;
4080}
4081
4082
4083
4084
4085tSirRetStatus limStaSendAddBssPreAssoc( tpAniSirGlobal pMac, tANI_U8 updateEntry, tpPESession psessionEntry)
4086{
4087 tSirMsgQ msgQ;
4088 tpAddBssParams pAddBssParams = NULL;
4089 tANI_U32 retCode;
4090 tANI_U8 i;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004091 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07004093 tANI_U32 shortGi20MhzSupport;
4094 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 tpSirBssDescription bssDescription = &psessionEntry->pLimJoinReq->bssDescription;
4096
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304097 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
4098 if (NULL == pBeaconStruct)
Jeff Johnson32d95a32012-09-10 13:15:23 -07004099 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304100 limLog(pMac, LOGE, FL("Unable to allocate memory during ADD_BSS") );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004101 return eSIR_MEM_ALLOC_FAILED;
4102 }
4103
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304106 pAddBssParams = vos_mem_malloc(sizeof(tAddBssParams));
4107 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 {
4109 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304110 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 retCode = eSIR_MEM_ALLOC_FAILED;
4112 goto returnFailure;
4113 }
4114
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304115 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116
4117
4118 limExtractApCapabilities( pMac,
4119 (tANI_U8 *) bssDescription->ieFields,
Abhishek Singhbad2b322016-10-21 11:22:33 +05304120 GET_IE_LEN_IN_BSS(bssDescription->length),
Jeff Johnson32d95a32012-09-10 13:15:23 -07004121 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07004122
4123 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson32d95a32012-09-10 13:15:23 -07004124 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304125 vos_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
4126 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004127
4128 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304129 vos_mem_copy(pAddBssParams->selfMacAddr,
4130 psessionEntry->selfMacAddr,
4131 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304132 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
4133 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004134
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304135 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
4136 MAC_ADDR_ARRAY(pAddBssParams->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304138 * top of an already established Infra link. This lead to issues in
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 * concurrent data transfer.
4140 */
4141
4142 pAddBssParams->bssType = psessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
4143 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
4144
4145 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
4146
Jeff Johnson32d95a32012-09-10 13:15:23 -07004147 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 pAddBssParams->updateBss = updateEntry;
4149
4150
Jeff Johnson32d95a32012-09-10 13:15:23 -07004151 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
4152 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
4153 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
4154 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -07004155
4156
Jeff Johnson32d95a32012-09-10 13:15:23 -07004157 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304158 vos_mem_copy(pAddBssParams->rateSet.rate,
4159 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07004160
4161 pAddBssParams->nwType = bssDescription->nwType;
4162
Jeff Johnson32d95a32012-09-10 13:15:23 -07004163 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
4165 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
4166 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304167 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
Jeff Johnson295189b2012-06-20 16:38:30 -07004168
Abhishek Singh525045c2014-12-15 17:18:45 +05304169 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304170 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
4171 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
4172
Abhishek Singh525045c2014-12-15 17:18:45 +05304173 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304174 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
4175 pAddBssParams->cfParamSet.cfpMaxDuration,
4176 pAddBssParams->cfParamSet.cfpDurRemaining,
4177 pAddBssParams->rateSet.numRates);
4178
Abhishek Singh525045c2014-12-15 17:18:45 +05304179 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304180 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
4181 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
4182 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
4183 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 // Use the advertised capabilities from the received beacon/PR
Jeff Johnson32d95a32012-09-10 13:15:23 -07004185 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004187 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05304188 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004189 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004191 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
4192 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07004193
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004195 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 (chanWidthSupp) )
4197 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004198 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
4199 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 }
4201 else
4202 {
4203 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004204 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004206 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
4207 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
4208 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304209
Abhishek Singh525045c2014-12-15 17:18:45 +05304210 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304211 "txChannelWidthSet: %d currentExtChannel: %d "),
4212 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
4213 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
4214
Abhishek Singh525045c2014-12-15 17:18:45 +05304215 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304216 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
4217 pAddBssParams->llnNonGFCoexist,
4218 pAddBssParams->fLsigTXOPProtectionFullSupport,
4219 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 }
4221 }
4222
4223 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05304224 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304225 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004226#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304227 if (psessionEntry->vhtCapability &&
4228 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Jeff Johnsone7245742012-09-05 17:12:55 -07004229 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004230 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
4231 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004232 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
4233 pAddBssParams->currentOperChannel,
4234 pAddBssParams->currentExtChannel,
4235 psessionEntry->apCenterChan,
4236 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004237 }
4238 else
4239 {
4240 pAddBssParams->vhtCapable = 0;
4241 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304242 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304243 "currentExtChannel %d"),pAddBssParams->vhtCapable,
4244 pAddBssParams->vhtTxChannelWidthSet,
4245 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004246#endif
4247
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 // Populate the STA-related parameters here
4249 // Note that the STA here refers to the AP
4250 {
4251 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
4252
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304253 vos_mem_copy(pAddBssParams->staContext.bssId,
4254 bssDescription->bssId,
4255 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
4257
4258 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
4259 pAddBssParams->staContext.uAPSD = 0;
4260 pAddBssParams->staContext.maxSPLen = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004261 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 pAddBssParams->staContext.updateSta = updateEntry;
4263
Abhishek Singh525045c2014-12-15 17:18:45 +05304264 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304265 " shortPreambleSupported: %d"),
4266 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
4267 pAddBssParams->staContext.shortPreambleSupported);
4268
Jeff Johnson32d95a32012-09-10 13:15:23 -07004269 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 {
4271 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
4272 pAddBssParams->staContext.htCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004273 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
4274 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05304275 limLog(pMac, LOG1, FL("StaContext htCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304276 "greenFieldCapable: %d lsigTxopProtection: %d"),
4277 pAddBssParams->staContext.htCapable,
4278 pAddBssParams->staContext.greenFieldCapable,
4279 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004280#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304281 if (psessionEntry->vhtCapability &&
4282 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004283 {
4284 pAddBssParams->staContext.vhtCapable = 1;
4285 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
4286 pBeaconStruct->VHTCaps.muBeamformerCap) &&
4287 psessionEntry->txBFIniFeatureEnabled )
4288 {
4289 pAddBssParams->staContext.vhtTxBFCapable = 1;
4290 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05304291 if (pBeaconStruct->VHTCaps.muBeamformerCap &&
4292 psessionEntry->txMuBformee )
4293 {
4294 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
4295 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
4296 /* Dont allow any other MuBf session as concurrency
4297 * is not supported
4298 */
4299 pMac->isMuBfsessionexist = TRUE;
4300 }
4301
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004302 }
4303#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004304 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 (chanWidthSupp) )
4306 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004307 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004308#ifdef WLAN_FEATURE_11AC
4309 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07004310 {
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004311 pAddBssParams->staContext.vhtTxChannelWidthSet =
4312 pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -07004313 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304314 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304315 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
4316 pAddBssParams->staContext.vhtCapable,
4317 pAddBssParams->staContext.vhtTxChannelWidthSet,
4318 pAddBssParams->staContext.vhtTxBFCapable);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004319#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 }
4321 else
4322 {
4323 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4324 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004325 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
4326 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
4327 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
4328 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
4329 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07004330 /*
4331 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
4332 * if they are set then we will use what ever Beacon coming from AP
4333 * supports. If these values are set as 0 in ini file then
4334 * we will hardcode this values to 0.
4335 */
4336 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4337 (pMac, WNI_CFG_SHORT_GI_20MHZ,
4338 &shortGi20MhzSupport)))
4339 {
4340 if (VOS_TRUE == shortGi20MhzSupport)
4341 {
4342 pAddBssParams->staContext.fShortGI20Mhz =
4343 (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
4344 }
4345 else
4346 {
4347 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
4348 }
4349 }
4350 else
4351 {
4352 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
4353 "CFG,setting value to default"));)
4354 pAddBssParams->staContext.fShortGI20Mhz =
4355 WNI_CFG_SHORT_GI_20MHZ_STADEF;
4356 }
4357
4358 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4359 (pMac, WNI_CFG_SHORT_GI_40MHZ,
4360 &shortGi40MhzSupport)))
4361 {
4362 if (VOS_TRUE == shortGi40MhzSupport)
4363 {
4364 pAddBssParams->staContext.fShortGI40Mhz =
4365 (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
4366 }
4367 else
4368 {
4369 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
4370 }
4371 }
4372 else
4373 {
4374 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
4375 "CFG,setting value to default"));)
4376 pAddBssParams->staContext.fShortGI40Mhz =
4377 WNI_CFG_SHORT_GI_40MHZ_STADEF;
4378 }
4379
Jeff Johnson32d95a32012-09-10 13:15:23 -07004380 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05304381 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08004382 {
4383 pAddBssParams->staContext.htLdpcCapable = 0;
4384 pAddBssParams->staContext.vhtLdpcCapable = 0;
4385 }
4386 else
4387 {
Abhishek Singh2fefebd2016-01-13 14:37:49 +05304388 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
4389 pAddBssParams->staContext.htLdpcCapable =
4390 (tANI_U8)pBeaconStruct->HTCaps.advCodingCap;
4391 else
4392 pAddBssParams->staContext.htLdpcCapable = 0;
4393 if (psessionEntry->txLdpcIniFeatureEnabled & 0x2)
4394 pAddBssParams->staContext.vhtLdpcCapable =
4395 (tANI_U8)pBeaconStruct->VHTCaps.ldpcCodingCap;
4396 else
4397 pAddBssParams->staContext.vhtLdpcCapable = 0;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08004398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004399
Jeff Johnson32d95a32012-09-10 13:15:23 -07004400 if( pBeaconStruct->HTInfo.present )
4401 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singh525045c2014-12-15 17:18:45 +05304402 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304403 " delBASupport: %d maxAmsduSize: %d"),
4404 pAddBssParams->staContext.txChannelWidthSet,
4405 pAddBssParams->staContext.mimoPS,
4406 pAddBssParams->staContext.delBASupport,
4407 pAddBssParams->staContext.maxAmsduSize);
4408
Abhishek Singh525045c2014-12-15 17:18:45 +05304409 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304410 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
4411 pAddBssParams->staContext.fDsssCckMode40Mhz,
4412 pAddBssParams->staContext.fShortGI20Mhz);
4413
Abhishek Singh525045c2014-12-15 17:18:45 +05304414 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304415 "htLdpcCapable: %d vhtLdpcCapable: %d"),
4416 pAddBssParams->staContext.fShortGI40Mhz,
4417 pAddBssParams->staContext.maxAmpduSize,
4418 pAddBssParams->staContext.htLdpcCapable,
4419 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 }
4421
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05304422 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
4423 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent || pAddBssParams->staContext.htCapable)) ||
4424 (psessionEntry->limQosEnabled && (pBeaconStruct->edcaPresent || pAddBssParams->staContext.htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 pAddBssParams->staContext.wmmEnabled = 1;
4426 else
4427 pAddBssParams->staContext.wmmEnabled = 0;
4428
4429 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -07004430#ifdef WLAN_FEATURE_11AC
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004431 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004432 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry,
4433 &pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -07004434#else
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004435 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004436 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,psessionEntry);
4439
4440 }
4441
4442
4443 //Disable BA. It will be set as part of ADDBA negotiation.
4444 for( i = 0; i < STACFG_MAX_TC; i++ )
4445 {
4446 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
4447 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
4448 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
4449 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
4450 }
4451
4452 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4453
4454#if defined WLAN_FEATURE_VOWIFI
4455 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05304456 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304457 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07004458#endif
4459
4460 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4461 pAddBssParams->respReqd = true;
4462
4463 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4464 pAddBssParams->sessionId = psessionEntry->peSessionId;
4465
4466 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4467
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004468 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004469
4470#if defined WLAN_FEATURE_VOWIFI_11R
4471 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05304472 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304473 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004474#endif
4475
Chet Lanctot186b5732013-03-18 10:26:30 -07004476#ifdef WLAN_FEATURE_11W
4477 if (psessionEntry->limRmfEnabled)
4478 {
4479 pAddBssParams->rmfEnabled = 1;
4480 pAddBssParams->staContext.rmfEnabled = 1;
4481 }
4482#endif
4483
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 // Set a new state for MLME
4485
4486 //pMac->lim.gLimMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4487 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4488
Jeff Johnsone7245742012-09-05 17:12:55 -07004489 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004490
Abhishek Singh525045c2014-12-15 17:18:45 +05304491 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304492 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
4493 pAddBssParams->staContext.encryptType,
4494 pAddBssParams->staContext.p2pCapableSta);
4495
Abhishek Singh525045c2014-12-15 17:18:45 +05304496 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304497 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
4498 pAddBssParams->halPersona, psessionEntry->limMlmState);
4499
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 //we need to defer the message until we get the response back from HAL.
4501 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4502
4503 msgQ.type = WDA_ADD_BSS_REQ;
4504 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4505 msgQ.reserved = 0;
4506 msgQ.bodyptr = pAddBssParams;
4507 msgQ.bodyval = 0;
4508
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05304509 limLog( pMac, LOG1, FL( "SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
4510 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004511 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004512
4513 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4514 if( eSIR_SUCCESS != retCode)
4515 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004516 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304517 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004518 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 retCode );
4520 goto returnFailure;
4521
4522 }
4523 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07004524 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304525 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 return retCode;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004528
4529 returnFailure:
4530 // Clean-up will be done by the caller...
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304531 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 return retCode;
4533}
4534
4535
4536
4537
4538
Jeff Johnson295189b2012-06-20 16:38:30 -07004539
4540/** -------------------------------------------------------------
4541\fn limPrepareAndSendDelStaCnf
4542\brief deletes DPH entry
4543 changes the MLM mode for station.
4544 calls limSendDelStaCnf
4545\param tpAniSirGlobal pMac
4546\param tpDphHashNode pStaDs
4547\return none
4548 -------------------------------------------------------------*/
4549
4550
4551void
4552limPrepareAndSendDelStaCnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tSirResultCodes statusCode,tpPESession psessionEntry)
4553{
4554 tANI_U16 staDsAssocId = 0;
4555 tSirMacAddr staDsAddr;
4556 tLimMlmStaContext mlmStaContext;
4557
4558 if(pStaDs == NULL)
4559 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004560 PELOGW(limLog(pMac, LOGW, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 return;
4562 }
4563 staDsAssocId = pStaDs->assocId;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304564 vos_mem_copy((tANI_U8 *)staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 pStaDs->staAddr,
4566 sizeof(tSirMacAddr));
4567
4568 mlmStaContext = pStaDs->mlmStaContext;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304569 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4570 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 {
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304572 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 }
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304574 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
4575
4576 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4577 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 {
4579 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304580 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
4581 psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 limSendDelStaCnf(pMac, staDsAddr, staDsAssocId, mlmStaContext, statusCode,psessionEntry);
4584}
4585
4586/** -------------------------------------------------------------
4587\fn limGetStaRateMode
4588\brief Gets the Station Rate Mode.
4589\param tANI_U8 dot11Mode
4590\return none
4591 -------------------------------------------------------------*/
4592tStaRateMode limGetStaRateMode(tANI_U8 dot11Mode)
4593{
4594 switch(dot11Mode)
4595 {
4596 case WNI_CFG_DOT11_MODE_11A:
4597 return eSTA_11a;
4598 case WNI_CFG_DOT11_MODE_11B:
4599 return eSTA_11b;
4600 case WNI_CFG_DOT11_MODE_11G:
4601 return eSTA_11bg;
4602 case WNI_CFG_DOT11_MODE_11N:
4603 return eSTA_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07004604#ifdef WLAN_FEATURE_11AC
4605 case WNI_CFG_DOT11_MODE_11AC:
4606 return eSTA_11ac;
4607#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 case WNI_CFG_DOT11_MODE_ALL:
4609 default:
4610 return eSTA_11n;
4611
4612 }
4613}
4614
4615/** -------------------------------------------------------------
4616\fn limInitPreAuthTimerTable
4617\brief Initialize the Pre Auth Tanle and creates the timer for
4618 each node for the timeout value got from cfg.
4619\param tpAniSirGlobal pMac
4620\param tpLimPreAuthTable pPreAuthTimerTable
4621\return none
4622 -------------------------------------------------------------*/
4623void limInitPreAuthTimerTable(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4624{
4625 tANI_U32 cfgValue;
4626 tANI_U32 authNodeIdx;
4627 tpLimPreAuthNode pAuthNode = pPreAuthTimerTable->pTable;
4628
4629 // Get AUTH_RSP Timers value
4630
4631 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4632 &cfgValue) != eSIR_SUCCESS)
4633 {
4634 /*
4635 ** Could not get AUTH_RSP timeout value
4636 ** from CFG. Log error.
4637 **/
4638 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004639 FL("could not retrieve AUTH_RSP timeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 return;
4641 }
4642
4643 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4644 for(authNodeIdx=0; authNodeIdx<pPreAuthTimerTable->numEntry; authNodeIdx++, pAuthNode++)
4645 {
4646 if (tx_timer_create(&pAuthNode->timer,
4647 "AUTH RESPONSE TIMEOUT",
4648 limAuthResponseTimerHandler,
4649 authNodeIdx,
4650 cfgValue,
4651 0,
4652 TX_NO_ACTIVATE) != TX_SUCCESS)
4653 {
4654 // Cannot create timer. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004655 limLog(pMac, LOGP, FL("Cannot create Auth Rsp timer of Index :%d."), authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 return;
4657 }
4658 pAuthNode->authNodeIdx = (tANI_U8)authNodeIdx;
4659 pAuthNode->fFree = 1;
4660 }
4661
4662}
4663
4664/** -------------------------------------------------------------
4665\fn limAcquireFreePreAuthNode
4666\brief Retrives a free Pre Auth node from Pre Auth Table.
4667\param tpAniSirGlobal pMac
4668\param tpLimPreAuthTable pPreAuthTimerTable
4669\return none
4670 -------------------------------------------------------------*/
4671tLimPreAuthNode * limAcquireFreePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4672{
4673 tANI_U32 i;
4674 tLimPreAuthNode *pTempNode = pPreAuthTimerTable->pTable;
4675 for (i=0; i<pPreAuthTimerTable->numEntry; i++,pTempNode++)
4676 {
4677 if (pTempNode->fFree == 1)
4678 {
4679 pTempNode->fFree = 0;
4680 return pTempNode;
4681 }
4682 }
4683
4684 return NULL;
4685}
4686
4687/** -------------------------------------------------------------
4688\fn limGetPreAuthNodeFromIndex
4689\brief Depending on the Index this retrives the pre auth node.
4690\param tpAniSirGlobal pMac
4691\param tpLimPreAuthTable pAuthTable
4692\param tANI_U32 authNodeIdx
4693\return none
4694 -------------------------------------------------------------*/
4695tLimPreAuthNode * limGetPreAuthNodeFromIndex(tpAniSirGlobal pMac,
4696 tpLimPreAuthTable pAuthTable, tANI_U32 authNodeIdx)
4697{
4698 if ((authNodeIdx >= pAuthTable->numEntry) || (pAuthTable->pTable == NULL))
4699 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004700 limLog(pMac, LOGE, FL("Invalid Auth Timer Index : %d NumEntry : %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 authNodeIdx, pAuthTable->numEntry);
4702 return NULL;
4703 }
4704
4705 return pAuthTable->pTable + authNodeIdx;
4706}
4707
4708/* Util API to check if the channels supported by STA is within range */
4709tSirRetStatus limIsDot11hSupportedChannelsValid(tpAniSirGlobal pMac, tSirAssocReq *assoc)
4710{
4711 /*
4712 * Allow all the stations to join with us.
4713 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4714 * as an input into an algorithm used to select a new channel for the BSS.
4715 * The specification of the algorithm is beyond the scope of this amendment.
4716 */
4717
4718 return (eSIR_SUCCESS);
4719}
4720
4721/* Util API to check if the txpower supported by STA is within range */
4722tSirRetStatus limIsDot11hPowerCapabilitiesInRange(tpAniSirGlobal pMac, tSirAssocReq *assoc,tpPESession psessionEntry)
4723{
4724 tPowerdBm localMaxTxPower;
4725 tANI_U32 localPwrConstraint;
4726
4727 localMaxTxPower = cfgGetRegulatoryMaxTransmitPower(pMac, psessionEntry->currentOperChannel);
4728
4729 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004730 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 return eSIR_FAILURE;
4732 }
4733 localMaxTxPower -= (tPowerdBm)localPwrConstraint;
4734
4735 /**
4736 * The min Tx Power of the associating station should not be greater than (regulatory
4737 * max tx power - local power constraint configured on AP).
4738 */
4739 if(assoc->powerCapability.minTxPower > localMaxTxPower)
4740 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004741 limLog(pMac, LOGW, FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 assoc->powerCapability.minTxPower, localMaxTxPower);
4743 return (eSIR_FAILURE);
4744 }
4745
4746 return (eSIR_SUCCESS);
4747}
4748
4749/** -------------------------------------------------------------
4750\fn limFillRxHighestSupportedRate
4751\brief Fills in the Rx Highest Supported Data Rate field from
4752\ the 'supported MCS set' field in HT capability element.
4753\param tpAniSirGlobal pMac
4754\param tpSirSupportedRates pRates
4755\param tANI_U8* pSupportedMCSSet
4756\return none
4757 -------------------------------------------------------------*/
4758void limFillRxHighestSupportedRate(tpAniSirGlobal pMac, tANI_U16 *rxHighestRate, tANI_U8* pSupportedMCSSet)
4759{
4760 tSirMacRxHighestSupportRate *pRxHighestRate;
4761 tANI_U8 *pBuf;
4762 tANI_U16 rate=0;
4763
4764 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4765 rate = limGetU16(pBuf);
4766
4767 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4768 *rxHighestRate = pRxHighestRate->rate;
4769
4770 return;
4771}
Chet Lanctot186b5732013-03-18 10:26:30 -07004772
4773#ifdef WLAN_FEATURE_11W
4774/** -------------------------------------------------------------
4775\fn limSendSmeUnprotectedMgmtFrameInd
4776\brief Forwards the unprotected management frame to SME.
4777\param tpAniSirGlobal pMac
4778\param frameType - 802.11 frame type
4779\param frame - frame buffer
4780\param sessionId - id for the current session
4781\param psessionEntry - PE session context
4782\return none
4783 -------------------------------------------------------------*/
4784void limSendSmeUnprotectedMgmtFrameInd(
4785 tpAniSirGlobal pMac, tANI_U8 frameType,
4786 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
4787 tpPESession psessionEntry)
4788{
4789 tSirMsgQ mmhMsg;
4790 tSirSmeUnprotMgmtFrameInd * pSirSmeMgmtFrame = NULL;
4791 tANI_U16 length;
4792
4793 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4794
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304795 pSirSmeMgmtFrame = vos_mem_malloc(length);
4796 if (NULL == pSirSmeMgmtFrame)
Chet Lanctot186b5732013-03-18 10:26:30 -07004797 {
4798 limLog(pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304799 FL("AllocateMemory failed for tSirSmeUnprotectedMgmtFrameInd"));
Chet Lanctot186b5732013-03-18 10:26:30 -07004800 return;
4801 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304802 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Chet Lanctot186b5732013-03-18 10:26:30 -07004803
4804 pSirSmeMgmtFrame->sessionId = sessionId;
4805 pSirSmeMgmtFrame->frameType = frameType;
4806
4807 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
4808 pSirSmeMgmtFrame->frameLen = frameLen;
4809
4810 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4811 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4812 mmhMsg.bodyval = 0;
4813
4814 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4815 return;
4816}
4817#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004818
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004819#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004820/** -------------------------------------------------------------
4821\fn limSendSmeTsmIEInd
4822\brief Forwards the TSM IE information to SME.
4823\param tpAniSirGlobal pMac
4824\param psessionEntry - PE session context
4825\param tid - traffic id
4826\param state - tsm state (enabled/disabled)
4827\param measurementInterval - measurement interval
4828\return none
4829 -------------------------------------------------------------*/
4830void limSendSmeTsmIEInd(tpAniSirGlobal pMac, tpPESession psessionEntry,
4831 tANI_U8 tid, tANI_U8 state, tANI_U16 measInterval)
4832{
4833 tSirMsgQ mmhMsg;
4834 tpSirSmeTsmIEInd pSirSmeTsmIeInd = NULL;
4835
4836 if (!pMac || !psessionEntry)
4837 {
4838 return;
4839 }
4840 pSirSmeTsmIeInd = vos_mem_malloc(sizeof(tSirSmeTsmIEInd));
4841 if (NULL == pSirSmeTsmIeInd)
4842 {
4843 limLog(pMac, LOGP,
4844 FL("AllocateMemory failed for tSirSmeTsmIEInd"));
4845 return;
4846 }
4847 vos_mem_set((void*)pSirSmeTsmIeInd, sizeof(tSirSmeTsmIEInd), 0);
4848
4849 pSirSmeTsmIeInd->sessionId = psessionEntry->smeSessionId;
4850 pSirSmeTsmIeInd->tsmIe.tsid = tid;
4851 pSirSmeTsmIeInd->tsmIe.state= state;
4852 pSirSmeTsmIeInd->tsmIe.msmt_interval= measInterval;
4853
4854 mmhMsg.type = eWNI_SME_TSM_IE_IND;
4855 mmhMsg.bodyptr = pSirSmeTsmIeInd;
4856 mmhMsg.bodyval = 0;
4857
4858 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4859 return;
4860}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004861#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004862
4863