blob: 555c68a4887c3e7a8bd6ef094f992ae2cecee3c2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05302 * Copyright (c) 2011-2015 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 */
693 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
694 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
695 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800696 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 }
698 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
699
700 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
746 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
747 retCode = limDelBss( pMac, pStaDs, psessionEntry->bssIdx, psessionEntry);
748 }
749 else
750 retCode = limDelSta( pMac, pStaDs, true, psessionEntry);
751
752 return retCode;
753
754} /*** end limCleanupRxPath() ***/
755
756
757/**
758 * limSendDelStaCnf()
759 *
760 *FUNCTION:
761 * This function is called to send appropriate CNF message to SME
762 *
763 *LOGIC:
764 *
765 *
766 *ASSUMPTIONS:
767 * NA
768 *
769 *NOTE:
770 * NA
771 *
772 * @param pMac Pointer to Global MAC structure
773 * @param tpAniSirGlobal pMac,
774 * @param tSirMacAddr staDsAddr,
775 * @param tANI_U16 staDsAssocId,
776 * @param tLimMlmStaContext mlmStaContext,
777 * @param tSirResultCodes statusCode
778 *
779 * @return None
780 */
781
782void
783limSendDelStaCnf(tpAniSirGlobal pMac, tSirMacAddr staDsAddr,
784 tANI_U16 staDsAssocId, tLimMlmStaContext mlmStaContext, tSirResultCodes statusCode,tpPESession psessionEntry)
785{
786
787 tLimMlmDisassocCnf mlmDisassocCnf;
788 tLimMlmDeauthCnf mlmDeauthCnf;
789 tLimMlmPurgeStaInd mlmPurgeStaInd;
790
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530791 limLog(pMac, LOG1, FL("Sessionid: %d staDsAssocId: %d Trigger: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +0530792 "statusCode: %d staDsAddr: "MAC_ADDRESS_STR),psessionEntry->peSessionId,
793 staDsAssocId, mlmStaContext.cleanupTrigger, statusCode,
794 MAC_ADDR_ARRAY(staDsAddr));
795
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
797 {
798 // Set BSSID at CFG to null
799 tSirMacAddr nullAddr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
800 #if 0
801 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) &nullAddr,
802 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
803 {
804 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700805 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700806
807 return;
808 }
809 #endif//TO SUPPORT BT-AMP
810
811 sirCopyMacAddr(nullAddr,psessionEntry->bssId);
812
813 // Free up buffer allocated for JoinReq held by
814 // MLM state machine
815 if (psessionEntry->pLimMlmJoinReq)
816 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530817 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 psessionEntry->pLimMlmJoinReq = NULL;
819 }
820
821 psessionEntry->limAID = 0;
822
823
824 }
825
826 if ((mlmStaContext.cleanupTrigger ==
827 eLIM_HOST_DISASSOC) ||
828 (mlmStaContext.cleanupTrigger ==
829 eLIM_LINK_MONITORING_DISASSOC) ||
830 (mlmStaContext.cleanupTrigger ==
831 eLIM_PROMISCUOUS_MODE_DISASSOC))
832 {
833 /**
834 * Host or LMM driven Disassociation.
835 * Issue Disassoc Confirm to SME.
836 */
Sachin Ahuja2fea3d12014-12-18 17:31:31 +0530837 limLog( pMac, LOGW, FL("Lim Posting DISASSOC_CNF to Sme.Trigger: %d"),
838 mlmStaContext.cleanupTrigger);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839
840
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530841 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
842 (tANI_U8 *) staDsAddr,
843 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 mlmDisassocCnf.resultCode = statusCode;
Wu Gao742b7352015-10-16 19:10:40 +0800845 mlmDisassocCnf.aid = staDsAssocId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 mlmDisassocCnf.disassocTrigger =
847 mlmStaContext.cleanupTrigger;
848 /* Update PE session Id*/
849 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
850
851 limPostSmeMessage(pMac,
852 LIM_MLM_DISASSOC_CNF,
853 (tANI_U32 *) &mlmDisassocCnf);
854 }
855 else if ((mlmStaContext.cleanupTrigger ==
856 eLIM_HOST_DEAUTH) ||
857 (mlmStaContext.cleanupTrigger ==
858 eLIM_LINK_MONITORING_DEAUTH))
859 {
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;
1014
Abhishek Singhdcbd8272014-01-09 14:16:01 +05301015 limLog(pMac, LOG1, FL("Sessionid: %d authType: %d subType: %d "
1016 "addPreAuthContext: %d staId: %d deleteSta: %d rCode : %d "
1017 "peerAddr: "MAC_ADDRESS_STR),psessionEntry->peSessionId,
1018 authType, subType, addPreAuthContext, staId, deleteSta, rCode,
1019 MAC_ADDR_ARRAY(peerAddr));
1020
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 if (addPreAuthContext)
1022 {
1023 // Create entry for this STA in pre-auth list
1024 struct tLimPreAuthNode *pAuthNode;
1025
1026 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
1027
1028 if (pAuthNode)
1029 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301030 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 peerAddr,
1032 sizeof(tSirMacAddr));
1033 pAuthNode->fTimerStarted = 0;
1034 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
1035 pAuthNode->authType = (tAniAuthType) authType;
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +05301036 pAuthNode->timestamp = vos_timer_get_system_ticks();
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 limAddPreAuthNode(pMac, pAuthNode);
1038 }
1039 }
1040
1041 if (deleteSta == true)
1042 {
1043 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
1044
1045 if (pStaDs == NULL)
1046 {
1047 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001048 FL("No STA context, yet rejecting Association"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001049
1050 return;
1051 }
1052
1053 /**
1054 * Polaris has state for this STA.
1055 * Trigger cleanup.
1056 */
1057 pStaDs->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
1058
1059 // Receive path cleanup
1060 limCleanupRxPath(pMac, pStaDs, psessionEntry);
1061
1062 // Send Re/Association Response with
1063 // status code to requesting STA.
1064 limSendAssocRspMgmtFrame(pMac,
1065 rCode,
1066 0,
1067 peerAddr,
1068 subType, 0,psessionEntry);
1069
1070 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL)
1071 {
1072 // Assoction confirmation is complete, free the copy of association request frame
1073 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
1074 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301075 vos_mem_free(((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07001076 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
1077 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301078 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
1080 }
1081 }
1082 else
1083 {
1084 limSendAssocRspMgmtFrame(pMac,
1085 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
1086 1,
1087 peerAddr,
1088 subType, 0,psessionEntry);
1089 // Log error
1090 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001091 FL("received Re/Assoc req when max associated STAs reached from "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 limPrintMacAddr(pMac, peerAddr, LOGW);
1093 limSendSmeMaxAssocExceededNtf(pMac, peerAddr, psessionEntry->smeSessionId);
1094 }
1095} /*** end limRejectAssociation() ***/
1096
Jeff Johnson295189b2012-06-20 16:38:30 -07001097
1098/** -------------------------------------------------------------
1099\fn limDecideApProtectionOnHt20Delete
1100\brief protection related function while HT20 station is getting deleted.
1101\param tpAniSirGlobal pMac
1102\param tpDphHashNode pStaDs
1103\param tpUpdateBeaconParams pBeaconParams
1104\return None
1105 -------------------------------------------------------------*/
1106static void
1107limDecideApProtectionOnHt20Delete(tpAniSirGlobal pMac,
1108 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1109{
1110 tANI_U32 i = 0;
1111 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT 20 STA is disassociated. Addr is "),
1112 psessionEntry->gLimHt20Params.numSta);
1113 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1114 if (psessionEntry->gLimHt20Params.numSta > 0)
1115 {
1116 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1117 {
1118 if (psessionEntry->protStaCache[i].active)
1119 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301120 if (vos_mem_compare(psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 pStaDs->staAddr, sizeof(tSirMacAddr)))
1122 {
1123 psessionEntry->gLimHt20Params.numSta--;
1124 psessionEntry->protStaCache[i].active = false;
1125 break;
1126 }
1127 }
1128 }
1129 }
1130
1131 if (psessionEntry->gLimHt20Params.numSta == 0)
1132 {
1133 // disable protection
Nirav Shahbc35fb72013-12-12 18:14:06 +05301134 limLog(pMac, LOG1, FL("No 11B STA exists, PESessionID %d"),
1135 psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
1137 }
1138}
1139/** -------------------------------------------------------------
1140\fn limDecideApProtectionOnDelete
1141\brief Decides about protection related settings when a station is getting deleted.
1142\param tpAniSirGlobal pMac
1143\param tpDphHashNode pStaDs
1144\param tpUpdateBeaconParams pBeaconParams
1145\return None
1146 -------------------------------------------------------------*/
1147void
1148limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
1149 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1150{
1151 tANI_U32 phyMode;
1152 tHalBitVal erpEnabled = eHAL_CLEAR;
1153 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1154 tANI_U32 i;
1155
1156 if(NULL == pStaDs)
1157 return;
1158
1159 limGetRfBand(pMac, &rfBand, psessionEntry);
1160 if(SIR_BAND_5_GHZ == rfBand)
1161 {
1162 //we are HT. if we are 11A, then protection is not required.
Jeff Johnsone7245742012-09-05 17:12:55 -07001163 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 {
1165 //we are HT and 11A station is leaving.
1166 //protection consideration required.
1167 //HT station leaving ==> this case is commonly handled between both the bands below.
1168 if((psessionEntry->beaconParams.llaCoexist) &&
1169 (false == pStaDs->mlmStaContext.htCapability))
1170 {
1171 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11A STA is disassociated. Addr is "),
1172 psessionEntry->gLim11aParams.numSta);
1173 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1174 if (psessionEntry->gLim11aParams.numSta > 0)
1175 {
1176 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1177 {
1178 if (psessionEntry->protStaCache[i].active)
1179 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301180 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 pStaDs->staAddr, sizeof(tSirMacAddr)))
1182 {
1183 psessionEntry->gLim11aParams.numSta--;
1184 psessionEntry->protStaCache[i].active = false;
1185 break;
1186 }
1187 }
1188 }
1189 }
1190
1191 if(psessionEntry->gLim11aParams.numSta == 0)
1192 {
1193 // disable protection
1194 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
1195 }
1196 }
1197 }
1198 }
1199 else if(SIR_BAND_2_4_GHZ == rfBand)
1200 {
1201 limGetPhyMode(pMac, &phyMode, psessionEntry);
1202
1203 erpEnabled = pStaDs->erpEnabled;
1204 //we are HT or 11G and 11B station is getting deleted.
1205 if (((phyMode == WNI_CFG_PHY_MODE_11G) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001206 psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 (erpEnabled == eHAL_CLEAR))
1208 {
1209 PELOG1(limLog(pMac, LOG1, FL("(%d) A legacy STA is disassociated. Addr is "),
1210 psessionEntry->gLim11bParams.numSta);
1211 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1212 if (psessionEntry->gLim11bParams.numSta > 0)
1213 {
1214 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1215 {
1216 if (psessionEntry->protStaCache[i].active)
1217 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301218 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 pStaDs->staAddr, sizeof(tSirMacAddr)))
1220 {
1221 psessionEntry->gLim11bParams.numSta--;
1222 psessionEntry->protStaCache[i].active = false;
1223 break;
1224 }
1225 }
1226 }
1227 }
1228
1229 if (psessionEntry->gLim11bParams.numSta == 0)
1230 {
1231 // disable protection
Jeff Johnson295189b2012-06-20 16:38:30 -07001232 limEnable11gProtection(pMac, false, false, pBeaconParams,psessionEntry);
1233 }
1234 }
1235 //(non-11B station is leaving) or (we are not 11G or HT AP)
Jeff Johnsone7245742012-09-05 17:12:55 -07001236 else if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 { //we are HT AP and non-11B station is leaving.
1238
1239 //11g station is leaving
1240 if(!pStaDs->mlmStaContext.htCapability)
1241 {
1242 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11g STA is disassociated. Addr is "),
1243 psessionEntry->gLim11bParams.numSta);
1244 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1245 if (psessionEntry->gLim11gParams.numSta > 0)
1246 {
1247 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1248 {
1249 if (psessionEntry->protStaCache[i].active)
1250 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301251 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 pStaDs->staAddr, sizeof(tSirMacAddr)))
1253 {
1254 psessionEntry->gLim11gParams.numSta--;
1255 psessionEntry->protStaCache[i].active = false;
1256 break;
1257 }
1258 }
1259 }
1260 }
1261
1262 if (psessionEntry->gLim11gParams.numSta == 0)
1263 {
1264 // disable protection
1265 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
1266 }
1267 }
1268 }
1269 }
1270
1271 //LSIG TXOP not supporting staiton leaving. applies to 2.4 as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07001272 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 (true == pStaDs->mlmStaContext.htCapability))
1274 {
1275 //HT non-GF leaving
1276 if(!pStaDs->htGreenfield)
1277 {
1278 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-GF STA is disassociated. Addr is "),
1279 psessionEntry->gLimNonGfParams.numSta);
1280 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1281 if (psessionEntry->gLimNonGfParams.numSta > 0)
1282 {
1283 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1284 {
1285 if (psessionEntry->protStaCache[i].active)
1286 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301287 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001288 pStaDs->staAddr, sizeof(tSirMacAddr)))
1289 {
1290 psessionEntry->gLimNonGfParams.numSta--;
1291 psessionEntry->protStaCache[i].active = false;
1292 break;
1293 }
1294 }
1295 }
1296 }
1297
1298 if (psessionEntry->gLimNonGfParams.numSta == 0)
1299 {
1300 // disable protection
1301 limEnableHTNonGfProtection(pMac, false, false, pBeaconParams,psessionEntry);
1302 }
1303 }
1304 //HT 20Mhz station leaving.
1305 if(psessionEntry->beaconParams.ht20Coexist &&
1306 (eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet))
1307 {
1308 limDecideApProtectionOnHt20Delete(pMac, pStaDs, pBeaconParams,psessionEntry);
1309 }
1310
1311 if(false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport &&
1312 (false == pStaDs->htLsigTXOPProtection))
1313 {
1314 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is "),
1315 psessionEntry->gLimLsigTxopParams.numSta);
1316 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1317 if (psessionEntry->gLimLsigTxopParams.numSta > 0)
1318 {
1319 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1320 {
1321 if (psessionEntry->protStaCache[i].active)
1322 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301323 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 pStaDs->staAddr, sizeof(tSirMacAddr)))
1325 {
1326 psessionEntry->gLimLsigTxopParams.numSta--;
1327 psessionEntry->protStaCache[i].active = false;
1328 break;
1329 }
1330 }
1331 }
1332 }
1333
1334 if (psessionEntry->gLimLsigTxopParams.numSta == 0)
1335 {
1336 // disable protection
1337 limEnableHTLsigTxopProtection(pMac, true, false, pBeaconParams,psessionEntry);
1338 }
1339 }
1340 }
1341}
1342
Jeff Johnson295189b2012-06-20 16:38:30 -07001343
1344
1345/** -------------------------------------------------------------
1346\fn limDecideShortPreamble
1347\brief Decides about any short preamble reated change because of new station joining.
1348\param tpAniSirGlobal pMac
1349\param tpDphHashNode pStaDs
1350\param tpUpdateBeaconParams pBeaconParams
1351\return None
1352 -------------------------------------------------------------*/
1353void limDecideShortPreamble(tpAniSirGlobal pMac,
1354 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry )
1355{
1356 tANI_U32 i;
1357
1358 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
1359 {
1360 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short preamble STA is disassociated. Addr is "),
1361 psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
1362 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1363 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta > 0)
1364 {
1365 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1366 {
1367 if (psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
1368 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301369 if (vos_mem_compare( psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 pStaDs->staAddr, sizeof(tSirMacAddr)))
1371 {
1372 psessionEntry->gLimNoShortParams.numNonShortPreambleSta--;
1373 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = false;
1374 break;
1375 }
1376 }
1377 }
1378 }
1379
1380 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta == 0)
1381 {
1382 // enable short preamble
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301384 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortParams,
1385 sizeof(tLimNoShortParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 if (limEnableShortPreamble(pMac, true, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001387 PELOGE(limLog(pMac, LOGE, FL("Cannot enable short preamble"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 }
1389 }
1390}
1391
1392/** -------------------------------------------------------------
1393\fn limDecideShortSlot
1394\brief Decides about any short slot time related change because of station leaving the BSS.
1395\param tpAniSirGlobal pMac
1396\param tpDphHashNode pStaDs
1397\return None
1398 -------------------------------------------------------------*/
1399
1400void
1401limDecideShortSlot(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1402 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1403{
1404 tANI_U32 i, val;
1405 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
1406 {
1407 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short slottime STA is disassociated. Addr is "),
1408 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
1409 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1410
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1412 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta> 0)
1413 {
1414 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1415 {
1416 if (psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1417 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301418 if (vos_mem_compare(psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 pStaDs->staAddr, sizeof(tSirMacAddr)))
1420 {
1421 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta--;
1422 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1423 break;
1424 }
1425 }
1426 }
1427 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001428 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 {
1430 if (pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta> 0)
1431 {
1432 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1433 {
1434 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1435 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301436 if (vos_mem_compare(pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 pStaDs->staAddr, sizeof(tSirMacAddr)))
1438 {
1439 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta--;
1440 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1441 break;
1442 }
1443 }
1444 }
1445 }
1446 }
1447
1448 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
1449
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1451 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta == 0))
1452 {
1453 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301455 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortSlotParams,
1456 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001457 // in case of AP set SHORT_SLOT_TIME to enable
1458 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1459 {
1460 pBeaconParams->fShortSlotTime = true;
1461 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001462 psessionEntry->shortSlotTimeSupported = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 }
1464 }
1465 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 {
1467 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta == 0)
1468 {
1469 // enable short slot time
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301471 vos_mem_set((tANI_U8 *)&pMac->lim.gLimNoShortSlotParams,
1472 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 // in case of AP set SHORT_SLOT_TIME to enable
1474 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1475 {
1476 pBeaconParams->fShortSlotTime = true;
1477 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001478 psessionEntry->shortSlotTimeSupported = true;
1479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 }
1481 }
1482 }
1483}
1484
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001485void
1486limPostReassocFailure(tpAniSirGlobal pMac,
1487 tSirResultCodes resultCode,
1488 tANI_U16 protStatusCode,tpPESession psessionEntry)
1489{
1490 tLimMlmReassocCnf mlmReassocCnf;
1491
1492 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1493 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
1494
1495 // 'Change' timer for future activations
1496 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1497
1498 mlmReassocCnf.resultCode = resultCode;
1499 mlmReassocCnf.protStatusCode = protStatusCode;
1500 /* Update PE session Id */
1501 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1502 limPostSmeMessage(pMac,
1503 LIM_MLM_REASSOC_CNF,
1504 (tANI_U32 *) &mlmReassocCnf);
1505} /*** end limPostReassocFailure() ***/
1506
Jeff Johnson295189b2012-06-20 16:38:30 -07001507/**
1508 * limRestorePreReassocState()
1509 *
1510 *FUNCTION:
1511 * This function is called on STA role whenever Reasociation
1512 * Response with a reject code is received from AP.
1513 *
1514 *LOGIC:
1515 * Reassociation failure timer is stopped, Old (or current) AP's
1516 * context is restored both at Polaris & software
1517 *
1518 *ASSUMPTIONS:
1519 *
1520 *NOTE:
1521 *
1522 * @param pMac - Pointer to Global MAC structure
1523 * @param resultCode - Result code that specifies why Reassociation
1524 * attemp failed
1525 *
1526 * @return None
1527 */
1528
1529void
1530limRestorePreReassocState(tpAniSirGlobal pMac,
1531 tSirResultCodes resultCode,
1532 tANI_U16 protStatusCode,tpPESession psessionEntry)
1533{
Jeff Johnsone7245742012-09-05 17:12:55 -07001534 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 tLimMlmReassocCnf mlmReassocCnf;
1536
Abhishek Singhdcbd8272014-01-09 14:16:01 +05301537 limLog(pMac, LOG1, FL("sessionid: %d protStatusCode: %d resultCode: %d"),
1538 psessionEntry->smeSessionId, protStatusCode, resultCode);
1539
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001541 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001542
1543 // 'Change' timer for future activations
1544 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1545
1546 // Update BSSID at CFG database
1547 #if 0
1548 if (cfgSetStr(pMac, WNI_CFG_BSSID,
1549 pMac->lim.gLimCurrentBssId,
1550 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1551 {
1552 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001553 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001554 return;
1555 }
Madan Mohan Koyyalamudi70322d52012-10-18 20:07:33 -07001556 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001557
1558 // chanNum = pMac->lim.gLimCurrentChannelId;
1559
1560 /* To support BT-AMP */
1561 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07001562 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001563
Jeff Johnsone7245742012-09-05 17:12:55 -07001564 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001565
1566 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1567
1568 mlmReassocCnf.resultCode = resultCode;
1569 mlmReassocCnf.protStatusCode = protStatusCode;
1570 /* Update PE session Id */
1571 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1572 limPostSmeMessage(pMac,
1573 LIM_MLM_REASSOC_CNF,
1574 (tANI_U32 *) &mlmReassocCnf);
1575} /*** end limRestorePreReassocState() ***/
1576
1577
1578
1579/**
1580 * limIsReassocInProgress()
1581 *
1582 *FUNCTION:
1583 * This function is called to see if STA is in wt-reassoc-rsp state.
1584 *
1585 *LOGIC:
1586 *
1587 *ASSUMPTIONS:
1588 *
1589 *NOTE:
1590 *
1591 * @param pMac - Pointer to Global MAC structure
1592 *
1593 * @return eANI_BOOLEAN_TRUE When STA is waiting for Reassoc response from AP \n
1594 * else eANI_BOOLEAN_FALSE
1595 */
1596
1597eAniBoolean
1598limIsReassocInProgress(tpAniSirGlobal pMac,tpPESession psessionEntry)
1599{
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001600 if (psessionEntry == NULL)
1601 {
1602 return eANI_BOOLEAN_FALSE;
1603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 if(((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1605 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1606 (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1607 return eANI_BOOLEAN_TRUE;
1608
1609 return eANI_BOOLEAN_FALSE;
1610} /*** end limIsReassocInProgress() ***/
1611
Jeff Johnsone7245742012-09-05 17:12:55 -07001612#ifdef WLAN_FEATURE_11AC
1613tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
1614 tpSirSupportedRates pRates,
1615 tDot11fIEVHTCaps *pPeerVHTCaps,
1616 tpPESession psessionEntry)
1617{
1618 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001619 tANI_U32 selfStaDot11Mode=0;
1620 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001622// if(IS_DOT11_MODE_VHT(psessionEntry->dot11mode))
1623 if (IS_DOT11_MODE_VHT(selfStaDot11Mode))
Jeff Johnsone7245742012-09-05 17:12:55 -07001624 {
1625 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_MCS_MAP,&val) !=
1626 eSIR_SUCCESS )
1627 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001628 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001629 goto error;
1630 }
1631 pRates->vhtRxMCSMap = (tANI_U16)val;
1632
1633 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_MCS_MAP,&val ) !=
1634 eSIR_SUCCESS )
1635 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001636 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT TX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 goto error;
1638 }
1639 pRates->vhtTxMCSMap = (tANI_U16)val;
1640
1641 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1642 eSIR_SUCCESS )
1643 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001644 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001645 goto error;
1646 }
1647 pRates->vhtRxHighestDataRate = (tANI_U16)val;
1648
1649 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1650 eSIR_SUCCESS )
1651 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001652 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001653 goto error;
1654 }
1655 pRates->vhtTxHighestDataRate = (tANI_U16)val;
1656
1657 if( pPeerVHTCaps != NULL)
1658 {
1659 pRates->vhtTxHighestDataRate = SIR_MIN(pRates->vhtTxHighestDataRate, pPeerVHTCaps->txSupDataRate);
1660 pRates->vhtRxHighestDataRate = SIR_MIN(pRates->vhtRxHighestDataRate, pPeerVHTCaps->rxHighSupDataRate);
1661
Jeff Johnson1250df42012-12-10 14:31:52 -08001662 // Acquire PEER MCS map if we exceed.
Jeff Johnsone7245742012-09-05 17:12:55 -07001663 // We compare/update only the last 2 bits of the map as we support only single BSS.
1664 // Firmware takes care of this comparison
1665 pRates->vhtRxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1666 pRates->vhtRxMCSMap |= (pPeerVHTCaps->rxMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1667
1668 // Firmware takes care of this comparison
1669 pRates->vhtTxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1670 pRates->vhtTxMCSMap |= (pPeerVHTCaps->txMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1671 }
1672 }
1673 return eSIR_SUCCESS;
1674error:
1675
1676 return eSIR_FAILURE;
1677
1678}
1679#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001680
1681/**
1682 * limPopulateOwnRateSet
1683 *
1684 * FUNCTION:
1685 * This function is called by limProcessAssocRsp() or
1686 * limAddStaInIBSS()
1687 * - It creates a combined rate set of 12 rates max which
1688 * comprises the basic and extended rates read from CFG
1689 * - It sorts the combined rate Set and copy it in the
1690 * rate array of the pSTA descriptor
1691 * - It sets the erpEnabled bit of the STA descriptor
1692 *
1693 * NOTE:
1694 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1695 * an A rate in the supported or extended rate sets
1696 *
1697 * @param pMac - Pointer to Global MAC structure
1698 * @param basicOnly - When passed value is true, only basic
1699 * rates are copied to DPH node else
1700 * all supported rates are copied
1701 * @return eSIR_SUCCESS or eSIR_FAILURE
1702 *
1703 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001704#ifdef WLAN_FEATURE_11AC
1705tSirRetStatus
1706limPopulateOwnRateSet(tpAniSirGlobal pMac,
1707 tpSirSupportedRates pRates,
1708 tANI_U8* pSupportedMCSSet,
1709 tANI_U8 basicOnly,
1710 tpPESession psessionEntry,
1711 tDot11fIEVHTCaps *pVHTCaps)
1712#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001713tSirRetStatus
1714limPopulateOwnRateSet(tpAniSirGlobal pMac,
1715 tpSirSupportedRates pRates,
1716 tANI_U8* pSupportedMCSSet,
1717 tANI_U8 basicOnly,
1718 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001719#endif
1720
Jeff Johnson295189b2012-06-20 16:38:30 -07001721{
1722 tSirMacRateSet tempRateSet;
1723 tSirMacRateSet tempRateSet2;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301724 tANI_U32 i,j,val,min,isArate;
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 tANI_U32 phyMode = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001726 tANI_U32 selfStaDot11Mode=0;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301727
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 isArate = 0;
1729
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001730 wlan_cfgGetInt(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 limGetPhyMode(pMac, &phyMode, psessionEntry);
1732
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301733 /* Include 11b rates only when the device configured in
1734 auto, 11a/b/g or 11b_only */
1735 if ( (selfStaDot11Mode == WNI_CFG_DOT11_MODE_ALL) ||
1736 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11A) ||
1737 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11AC) ||
Leela Venkata Kiran Kumar Reddy Chiralac9a10e52013-08-29 16:37:15 -07001738 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11N) ||
1739 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11G) ||
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301740 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11B) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301742 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1743 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11B,
1744 (tANI_U8 *)&tempRateSet.rate, &val );
1745 tempRateSet.numRates = (tANI_U8) val;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001746 }
1747 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301748 tempRateSet.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001749
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301750 /* Include 11a rates when the device configured in non-11b mode */
1751 if (!IS_DOT11_MODE_11B(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301753 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1754 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11A,
1755 (tANI_U8 *)&tempRateSet2.rate, &val );
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 tempRateSet2.numRates = (tANI_U8) val;
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 }
1758 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301759 tempRateSet2.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001760
1761 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1762 {
1763 //we are in big trouble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001764 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 //panic
1766 goto error;
1767 }
1768
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 //copy all rates in tempRateSet, there are 12 rates max
1770 for (i = 0;i < tempRateSet2.numRates; i++)
1771 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1772 tempRateSet.numRates += tempRateSet2.numRates;
1773
1774 /**
1775 * Sort rates in tempRateSet (they are likely to be already sorted)
1776 * put the result in pSupportedRates
1777 */
1778 {
1779 tANI_U8 aRateIndex = 0;
1780 tANI_U8 bRateIndex = 0;
1781
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301782 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 for(i = 0;i < tempRateSet.numRates; i++)
1784 {
1785 min = 0;
1786 val = 0xff;
1787 isArate = 0;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001788 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 {
1790 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1791 {
1792 val = tempRateSet.rate[j] & 0x7f;
1793 min = j;
1794 }
1795 }
1796
1797 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1798 isArate = 1;
1799
1800 /*
1801 * HAL needs to know whether the rate is basic rate or not, as it needs to
1802 * update the response rate table accordingly. e.g. if one of the 11a rates is
1803 * basic rate, then that rate can be used for sending control frames.
1804 * HAL updates the response rate table whenever basic rate set is changed.
1805 */
1806 if (basicOnly)
1807 {
1808 if (tempRateSet.rate[min] & 0x80)
1809 {
1810 if (isArate)
1811 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1812 else
1813 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1814 }
1815 }
1816 else
1817 {
1818 if (isArate)
1819 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1820 else
1821 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1822 }
1823 tempRateSet.rate[min] = 0xff;
1824 }
1825
1826 }
1827
1828
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001829 //if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1830 if (IS_DOT11_MODE_HT(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 {
1832 val = SIZE_OF_SUPPORTED_MCS_SET;
1833 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1834 pRates->supportedMCSSet,
1835 &val) != eSIR_SUCCESS)
1836 {
1837 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001838 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 goto error;
1840 }
1841
1842
1843 //if supported MCS Set of the peer is passed in, then do the intersection
1844 //else use the MCS set from local CFG.
1845
1846 if(pSupportedMCSSet != NULL)
1847 {
1848 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1849 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1850
1851 }
1852
Abhishek Singh525045c2014-12-15 17:18:45 +05301853 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05301855 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 }
1857
Jeff Johnsone7245742012-09-05 17:12:55 -07001858#ifdef WLAN_FEATURE_11AC
1859 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
1862 return eSIR_SUCCESS;
1863
1864 error:
1865
1866 return eSIR_FAILURE;
1867} /*** limPopulateOwnRateSet() ***/
1868
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001869#ifdef WLAN_FEATURE_11AC
1870tSirRetStatus
1871limPopulatePeerRateSet(tpAniSirGlobal pMac,
1872
1873 tpSirSupportedRates pRates,
1874 tANI_U8* pSupportedMCSSet,
1875 tANI_U8 basicOnly,
1876 tpPESession psessionEntry,
1877 tDot11fIEVHTCaps *pVHTCaps)
1878#else
1879tSirRetStatus
1880limPopulatePeerRateSet(tpAniSirGlobal pMac,
1881 tpSirSupportedRates pRates,
1882 tANI_U8* pSupportedMCSSet,
1883 tANI_U8 basicOnly,
1884 tpPESession psessionEntry)
1885#endif
1886{
1887 tSirMacRateSet tempRateSet;
1888 tSirMacRateSet tempRateSet2;
1889 tANI_U32 i,j,val,min,isArate;
1890 isArate = 0;
1891
1892 /* copy operational rate set from psessionEntry */
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001893 if ( psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX )
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001894 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301895 vos_mem_copy((tANI_U8 *)tempRateSet.rate,
1896 (tANI_U8*)(psessionEntry->rateSet.rate),
1897 psessionEntry->rateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001898 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1899 }
1900 else
1901 {
1902 limLog(pMac, LOGE, FL("more than SIR_MAC_RATESET_EID_MAX rates\n"));
1903 goto error;
1904 }
Leela Venkata Kiran Kumar Reddy Chirala891bf062013-10-03 14:30:53 -07001905 if ((psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1906 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1907 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11N))
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001908 {
1909
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001910 if (psessionEntry->extRateSet.numRates <= SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001911 {
Kiet Lam842c3e12013-11-16 22:40:57 +05301912 vos_mem_copy((tANI_U8 *)tempRateSet2.rate,
1913 (tANI_U8*)(psessionEntry->extRateSet.rate),
1914 psessionEntry->extRateSet.numRates);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001915 tempRateSet2.numRates = psessionEntry->extRateSet.numRates;
1916 }
1917 else {
1918 limLog(pMac, LOGE, FL("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates\n"));
1919 goto error;
1920 }
1921 }
1922 else
1923 tempRateSet2.numRates = 0;
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001924 if ((tempRateSet.numRates + tempRateSet2.numRates) > SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001925 {
1926 //we are in big trouble
1927 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
1928 goto error;
1929 }
1930
1931
1932 //copy all rates in tempRateSet, there are 12 rates max
1933 for (i = 0;i < tempRateSet2.numRates; i++)
1934 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1935 tempRateSet.numRates += tempRateSet2.numRates;
1936 /**
1937 * Sort rates in tempRateSet (they are likely to be already sorted)
1938 * put the result in pSupportedRates
1939 */
1940 {
1941 tANI_U8 aRateIndex = 0;
1942 tANI_U8 bRateIndex = 0;
Kiet Lam842c3e12013-11-16 22:40:57 +05301943 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001944 for(i = 0;i < tempRateSet.numRates; i++)
1945 {
1946 min = 0;
1947 val = 0xff;
1948 isArate = 0;
1949 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
1950 {
1951 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1952 {
1953 val = tempRateSet.rate[j] & 0x7f;
1954 min = j;
1955 }
1956 }
1957 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1958 isArate = 1;
1959 /*
1960 * HAL needs to know whether the rate is basic rate or not, as it needs to
1961 * update the response rate table accordingly. e.g. if one of the 11a rates is
1962 * basic rate, then that rate can be used for sending control frames.
1963 * HAL updates the response rate table whenever basic rate set is changed.
1964 */
1965 if (basicOnly)
1966 {
1967 if (tempRateSet.rate[min] & 0x80)
1968 {
1969 if (isArate)
1970 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1971 else
1972 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1973 }
1974 }
1975 else
1976 {
1977 if (isArate)
1978 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1979 else
1980 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1981 }
1982 tempRateSet.rate[min] = 0xff;
1983 }
1984 }
1985
1986
1987 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1988 {
1989 val = SIZE_OF_SUPPORTED_MCS_SET;
1990 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1991 pRates->supportedMCSSet,
1992 &val) != eSIR_SUCCESS)
1993 {
1994 /// Could not get rateset from CFG. Log error.
1995 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
1996 goto error;
1997 }
1998 //if supported MCS Set of the peer is passed in, then do the intersection
1999 //else use the MCS set from local CFG.
2000 if(pSupportedMCSSet != NULL)
2001 {
2002 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2003 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
2004 }
Abhishek Singh525045c2014-12-15 17:18:45 +05302005 limLog(pMac, LOG1, FL("MCS Rate Set Bitmap: "));
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002006 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Sushant Kaushik0b343422015-05-25 17:15:55 +05302007 limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07002008 }
2009#ifdef WLAN_FEATURE_11AC
2010 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
2011#endif
2012 return eSIR_SUCCESS;
2013 error:
2014 return eSIR_FAILURE;
2015} /*** limPopulatePeerRateSet() ***/
2016
Jeff Johnson295189b2012-06-20 16:38:30 -07002017/**
2018 * limPopulateMatchingRateSet
2019 * FUNCTION:
2020 * This is called at the time of Association Request
2021 * processing on AP and while adding peer's context
2022 * in IBSS role to process the CFG rate sets and
2023 * the rate sets received in the Assoc request on AP
2024 * or Beacon/Probe Response from peer in IBSS.
2025 *
2026 * LOGIC:
2027 * 1. It makes the intersection between our own rate Sat
2028 * and extemcded rate set and the ones received in the
2029 * association request.
2030 * 2. It creates a combined rate set of 12 rates max which
2031 * comprised the basic and extended rates
2032 * 3. It sorts the combined rate Set and copy it in the
2033 * rate array of the pSTA descriptor
2034 *
2035 * ASSUMPTION:
2036 * The parser has already ensured unicity of the rates in the
2037 * association request structure
2038 *
2039 * @param: pMac - Pointer to Global MAC structure
2040 * pStaDs - Pointer to DPH node
2041 * pOperRateSet - Pointer to peer's supported rateset
2042 * pExtRateSet - Pointer to peer's extended rateset
2043 *
2044 * @return: eSIR_SUCCESS or eSIR_FAILURE
2045 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002046#ifdef WLAN_FEATURE_11AC
2047tSirRetStatus
2048limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2049 tpDphHashNode pStaDs,
2050 tSirMacRateSet *pOperRateSet,
2051 tSirMacRateSet *pExtRateSet,
2052 tANI_U8* pSupportedMCSSet,
2053 tSirMacPropRateSet *pAniLegRateSet,
2054 tpPESession psessionEntry,
2055 tDot11fIEVHTCaps *pVHTCaps)
Jeff Johnson295189b2012-06-20 16:38:30 -07002056
Jeff Johnsone7245742012-09-05 17:12:55 -07002057#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002058tSirRetStatus
2059limPopulateMatchingRateSet(tpAniSirGlobal pMac,
2060 tpDphHashNode pStaDs,
2061 tSirMacRateSet *pOperRateSet,
2062 tSirMacRateSet *pExtRateSet,
2063 tANI_U8* pSupportedMCSSet,
2064 tSirMacPropRateSet *pAniLegRateSet,
2065 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07002066#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002067{
2068 tSirMacRateSet tempRateSet;
2069 tSirMacRateSet tempRateSet2;
2070 tANI_U32 i,j,val,min,isArate;
2071 tANI_U32 phyMode;
2072 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2073
2074 isArate=0;
2075
2076 // limGetPhyMode(pMac, &phyMode);
2077 limGetPhyMode(pMac, &phyMode, psessionEntry);
2078
2079 // get own rate set
2080 // val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2081 #if 0
2082 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2083 (tANI_U8 *) &tempRateSet.rate,
2084 &val) != eSIR_SUCCESS)
2085 {
2086 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002087 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 }
2089
2090 #endif // TO SUPPORT BT-AMP
2091
2092 /* copy operational rate set from psessionEntry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302093 vos_mem_copy((tempRateSet.rate), (psessionEntry->rateSet.rate),
2094 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 tempRateSet.numRates = (tANI_U8) psessionEntry->rateSet.numRates;
2096
2097 if (phyMode == WNI_CFG_PHY_MODE_11G)
2098 {
2099
2100 #if 0
2101 // get own extended rate set
2102 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2103 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
2104 (tANI_U8 *) &tempRateSet2.rate,
2105 &val) != eSIR_SUCCESS)
2106 #endif
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302107 vos_mem_copy((tempRateSet2.rate), (psessionEntry->extRateSet.rate),
2108 psessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 tempRateSet2.numRates = (tANI_U8) psessionEntry->extRateSet.numRates;
2110 }
2111 else
2112 tempRateSet2.numRates = 0;
2113
2114 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2115 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002116 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 goto error;
2118 }
2119
2120 /**
2121 * Handling of the rate set IEs is the following:
2122 * - keep only rates that we support and that the station supports
2123 * - sort and the rates into the pSta->rate array
2124 */
2125
2126 // Copy all rates in tempRateSet, there are 12 rates max
2127 for(i = 0; i < tempRateSet2.numRates; i++)
2128 tempRateSet.rate[i + tempRateSet.numRates] =
2129 tempRateSet2.rate[i];
2130
2131 tempRateSet.numRates += tempRateSet2.numRates;
2132
2133 /**
2134 * Sort rates in tempRateSet (they are likely to be already sorted)
2135 * put the result in tempRateSet2
2136 */
2137 tempRateSet2.numRates = 0;
2138
2139 for(i = 0;i < tempRateSet.numRates; i++)
2140 {
2141 min = 0;
2142 val = 0xff;
2143
2144 for(j = 0;j < tempRateSet.numRates; j++)
2145 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2146 {
2147 val = tempRateSet.rate[j] & 0x7f;
2148 min = j;
2149 }
2150
2151 tempRateSet2.rate[tempRateSet2.numRates++] =
2152 tempRateSet.rate[min];
2153 tempRateSet.rate[min] = 0xff;
2154 }
2155
2156
2157 /**
2158 * Copy received rates in tempRateSet, the parser has ensured
2159 * unicity of the rates so there cannot be more than 12
2160 */
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002161 for(i = 0; (i < pOperRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 {
2163 tempRateSet.rate[i] = pOperRateSet->rate[i];
2164 }
2165
2166 tempRateSet.numRates = pOperRateSet->numRates;
2167
2168 if (pExtRateSet->numRates)
2169 {
2170 if((tempRateSet.numRates + pExtRateSet->numRates) > 12 )
2171 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302172 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 "Sum of SUPPORTED and EXTENDED Rate Set (%1d) exceeds 12!",
2174 tempRateSet.numRates + pExtRateSet->numRates );
2175
2176 if( tempRateSet.numRates < 12 )
2177 {
2178 int found = 0;
2179 int tail = tempRateSet.numRates;
2180
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002181 for( i = 0; (i < pExtRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX); i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 {
2183 found = 0;
2184 for( j = 0; j < (tANI_U32) tail; j++ )
2185 {
2186 if((tempRateSet.rate[j] & 0x7F) ==
2187 (pExtRateSet->rate[i] & 0x7F))
2188 {
2189 found = 1;
2190 break;
2191 }
2192 }
2193
2194 if( !found )
2195 {
2196 tempRateSet.rate[tempRateSet.numRates++] =
2197 pExtRateSet->rate[i];
2198
2199 if( tempRateSet.numRates >= 12 )
2200 break;
2201 }
2202 }
2203 }
2204 else
Abhishek Singh525045c2014-12-15 17:18:45 +05302205 limLog( pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 "Relying only on the SUPPORTED Rate Set IE..." );
2207 }
2208 else
2209 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002210 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 -07002211 tempRateSet.rate[i+j] = pExtRateSet->rate[j];
2212
2213 tempRateSet.numRates += pExtRateSet->numRates;
2214 }
2215 }
2216
2217 {
2218 tpSirSupportedRates rates = &pStaDs->supportedRates;
2219 tANI_U8 aRateIndex = 0;
2220 tANI_U8 bRateIndex = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302221 vos_mem_set((tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002222 for(i = 0;(i < tempRateSet2.numRates && i < SIR_MAC_RATESET_EID_MAX ); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002224 for(j = 0;(j < tempRateSet.numRates && j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 {
2226 if ((tempRateSet2.rate[i] & 0x7F) ==
2227 (tempRateSet.rate[j] & 0x7F))
2228 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2230 {
2231 isArate=1;
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002232 if (aRateIndex < SIR_NUM_11A_RATES)
2233 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 }
2235 else
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002236 {
2237 if (bRateIndex < SIR_NUM_11B_RATES)
2238 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 break;
2241 }
2242 }
2243 }
2244
2245
2246 //Now add the Polaris rates only when Proprietary rates are enabled.
2247 val = 0;
2248 if(wlan_cfgGetInt(pMac, WNI_CFG_PROPRIETARY_RATES_ENABLED, &val) != eSIR_SUCCESS)
2249 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002250 limLog(pMac, LOGP, FL("could not retrieve prop rate enabled flag from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 }
2252 else if(val)
2253 {
2254 for(i=0; i<pAniLegRateSet->numPropRates; i++)
2255 rates->aniLegacyRates[i] = pAniLegRateSet->propRate[i];
2256 }
2257
2258 }
2259
2260
2261 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002262#ifdef FEATURE_WLAN_TDLS
2263 if(pStaDs->mlmStaContext.htCapability)
2264#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2266 (pStaDs->mlmStaContext.htCapability))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002267#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 {
2269 val = SIZE_OF_SUPPORTED_MCS_SET;
2270 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2271 mcsSet,
2272 &val) != eSIR_SUCCESS)
2273 {
2274 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002275 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 goto error;
2277 }
2278
2279 for(i=0; i<val; i++)
2280 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2281
Abhishek Singh525045c2014-12-15 17:18:45 +05302282 limLog(pMac, LOG1, FL(" MCS Rate Set Bitmap from CFG and DPH : "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2284 {
Abhishek Singh525045c2014-12-15 17:18:45 +05302285 limLog(pMac, LOG1,FL("%x %x "), mcsSet[i],
2286 pStaDs->supportedRates.supportedMCSSet[i]);
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 }
2288 }
2289
Jeff Johnsone7245742012-09-05 17:12:55 -07002290#ifdef WLAN_FEATURE_11AC
2291 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2292#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002293 /**
2294 * Set the erpEnabled bit iff the phy is in G mode and at least
2295 * one A rate is supported
2296 */
2297 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2298 pStaDs->erpEnabled = eHAL_SET;
2299
2300
2301
2302 return eSIR_SUCCESS;
2303
2304 error:
2305
2306 return eSIR_FAILURE;
2307} /*** limPopulateMatchingRateSet() ***/
2308
2309
2310
2311/**
2312 * limAddSta()
2313 *
2314 *FUNCTION:
2315 * This function is called to add an STA context at hardware
2316 * whenever a STA is (Re) Associated.
2317 *
2318 *LOGIC:
2319 *
2320 *ASSUMPTIONS:
2321 * NA
2322 *
2323 *NOTE:
2324 * NA
2325 *
2326 * @param pMac - Pointer to Global MAC structure
2327 * @param pStaDs - Pointer to the STA datastructure created by
2328 * LIM and maintained by DPH
2329 * @return retCode - Indicates success or failure return code
2330 */
2331
2332tSirRetStatus
2333limAddSta(
2334 tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002335 tpDphHashNode pStaDs, tANI_U8 updateEntry, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002336{
2337 tpAddStaParams pAddStaParams = NULL;
2338 tSirMsgQ msgQ;
2339 tSirRetStatus retCode = eSIR_SUCCESS;
2340 tSirMacAddr staMac, *pStaAddr;
2341 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 tpSirAssocReq pAssocReq;
2343 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 #if 0
2345 retCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2346 if (retCode != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002347 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 #endif //To SUPPORT BT-AMP
2349
2350
2351 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2352
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302353 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
2354 psessionEntry->smeSessionId, updateEntry, psessionEntry->limSystemRole);
2355
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302356 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2357 if (NULL == pAddStaParams)
2358 {
2359 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
2360 return eSIR_MEM_ALLOC_FAILED;
2361 }
2362 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363
2364 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||
2365 (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE) ||
2366 (limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) )
2367 pStaAddr = &pStaDs->staAddr;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002368#ifdef FEATURE_WLAN_TDLS
2369 /* SystemRole shouldn't be matter if staType is TDLS peer */
2370 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2371 {
2372 pStaAddr = &pStaDs->staAddr ;
2373 }
2374#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 else
2376 pStaAddr = &staMac;
2377
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302378 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": Subtype(Assoc/Reassoc): %d "),
2379 MAC_ADDR_ARRAY(*pStaAddr), pStaDs->mlmStaContext.subType);
2380
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302381 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2382 (tANI_U8 *) *pStaAddr, sizeof(tSirMacAddr));
2383 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2384 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
2387
2388 //Copy legacy rates
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302389 vos_mem_copy ((tANI_U8*)&pAddStaParams->supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 (tANI_U8*)&pStaDs->supportedRates, sizeof(tSirSupportedRates));
2391
2392 pAddStaParams->assocId = pStaDs->assocId;
2393
2394 pAddStaParams->wmmEnabled = pStaDs->qosMode;
2395 pAddStaParams->listenInterval = pStaDs->mlmStaContext.listenInterval;
2396 pAddStaParams->shortPreambleSupported = pStaDs->shortPreambleEnabled;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302397 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 if((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) && (pStaDs->mlmStaContext.subType == LIM_REASSOC))
2399 {
2400 /* TBD - need to remove this REASSOC check after fixinf rmmod issue */
2401 pAddStaParams->updateSta = pStaDs->mlmStaContext.updateContext;
2402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 pStaDs->valid = 0;
2404 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2405
Abhishek Singh525045c2014-12-15 17:18:45 +05302406 limLog(pMac, LOG1, FL(" Assoc ID: %d wmmEnabled = %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302407 " shortPreambleSupported: %d "), pAddStaParams->assocId,
2408 pAddStaParams->wmmEnabled, pAddStaParams->listenInterval,
2409 pAddStaParams->shortPreambleSupported);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002410 // This will indicate HAL to "allocate" a new STA index
2411#ifdef FEATURE_WLAN_TDLS
2412 /* As there is corner case in-between add_sta and change_sta,if del_sta for other staIdx happened,
2413 * firmware return wrong staIdx (recently removed staIdx). Until we get a confirmation from the
2414 * firmware team it is now return correct staIdx for same sta_mac_addr for update case, we want
2415 * to get around it by passing valid staIdx given by add_sta time.
2416 */
2417 if((STA_ENTRY_TDLS_PEER == pStaDs->staType) &&
2418 (true == updateEntry))
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302419 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002420 pAddStaParams->staIdx = pStaDs->staIndex;
Pradeep Reddy POTTETIe8bd41a2015-01-29 14:52:43 +05302421 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002422 else
2423#endif
2424 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 pAddStaParams->staType = pStaDs->staType;
2426
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002427 pAddStaParams->updateSta = updateEntry;
2428
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2430 pAddStaParams->respReqd = 1;
2431 //Update HT Capability
2432
2433 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 -07002434 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Jeff Johnsone7245742012-09-05 17:12:55 -07002436#ifdef WLAN_FEATURE_11AC
2437 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2438#endif
2439 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002440#ifdef FEATURE_WLAN_TDLS
2441 /* SystemRole shouldn't be matter if staType is TDLS peer */
2442 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
Hoonki Lee99e53782013-02-12 18:07:03 -08002443 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002444 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Hoonki Lee99e53782013-02-12 18:07:03 -08002445#ifdef WLAN_FEATURE_11AC
2446 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2447#endif
2448 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002449#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 else
Jeff Johnsone7245742012-09-05 17:12:55 -07002451 {
2452 pAddStaParams->htCapable = psessionEntry->htCapability;
2453#ifdef WLAN_FEATURE_11AC
2454 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
2455#endif
2456
2457 }
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302458#ifdef WLAN_FEATURE_11AC
Abhishek Singh525045c2014-12-15 17:18:45 +05302459 limLog(pMac, LOG1, FL("vhtCapable: %d "), pAddStaParams->vhtCapable);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302460#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302461 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302462 pAddStaParams->staIdx,pAddStaParams->updateSta,
2463 pAddStaParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002464
2465 pAddStaParams->greenFieldCapable = pStaDs->htGreenfield;
2466 pAddStaParams->maxAmpduDensity= pStaDs->htAMpduDensity;
2467 pAddStaParams->maxAmpduSize = pStaDs->htMaxRxAMpduFactor;
2468 pAddStaParams->fDsssCckMode40Mhz = pStaDs->htDsssCckRate40MHzSupport;
2469 pAddStaParams->fShortGI20Mhz = pStaDs->htShortGI20Mhz;
2470 pAddStaParams->fShortGI40Mhz = pStaDs->htShortGI40Mhz;
2471 pAddStaParams->lsigTxopProtection = pStaDs->htLsigTXOPProtection;
2472 pAddStaParams->maxAmsduSize = pStaDs->htMaxAmsduLength;
2473 pAddStaParams->txChannelWidthSet = pStaDs->htSupportedChannelWidthSet;
2474 pAddStaParams->mimoPS = pStaDs->htMIMOPSState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002475
Abhishek Singh525045c2014-12-15 17:18:45 +05302476 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302477 "maxAmpduDensity = %d"), pAddStaParams->greenFieldCapable,
2478 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
2479
Abhishek Singh525045c2014-12-15 17:18:45 +05302480 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302481 "fShortGI40Mhz: %d"), pAddStaParams->fDsssCckMode40Mhz,
2482 pAddStaParams->fShortGI20Mhz, pAddStaParams->fShortGI40Mhz);
2483
Abhishek Singh525045c2014-12-15 17:18:45 +05302484 limLog(pMac, LOG1, FL("lsigTxopProtection: %d maxAmsduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302485 "txChannelWidthSet: %d mimoPS: %d "), pAddStaParams->lsigTxopProtection,
2486 pAddStaParams->maxAmsduSize,pAddStaParams->txChannelWidthSet,
2487 pAddStaParams->mimoPS);
2488
Jeff Johnsone7245742012-09-05 17:12:55 -07002489#ifdef WLAN_FEATURE_11AC
2490 if(pAddStaParams->vhtCapable)
2491 {
Mohit Khanna7d5aeb22012-09-11 16:21:57 -07002492 pAddStaParams->vhtTxChannelWidthSet = pStaDs->vhtSupportedChannelWidthSet;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002493 pAddStaParams->vhtTxBFCapable =
Hoonki Lee99e53782013-02-12 18:07:03 -08002494#ifdef FEATURE_WLAN_TDLS
2495 (( STA_ENTRY_PEER == pStaDs->staType ) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) ?
2496 pStaDs->vhtBeamFormerCapable : psessionEntry->txBFIniFeatureEnabled ;
2497#else
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002498 ( STA_ENTRY_PEER == pStaDs->staType ) ? pStaDs->vhtBeamFormerCapable :
2499 psessionEntry->txBFIniFeatureEnabled ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002500#endif
Abhishek Singh525045c2014-12-15 17:18:45 +05302501 limLog(pMac, LOG1, FL("vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302502 pAddStaParams->vhtTxChannelWidthSet,pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07002503 }
2504#endif
2505
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002506#ifdef FEATURE_WLAN_TDLS
2507 if((STA_ENTRY_PEER == pStaDs->staType) ||
2508 (STA_ENTRY_TDLS_PEER == pStaDs->staType))
2509#else
2510 if (STA_ENTRY_PEER == pStaDs->staType)
2511#endif
2512 {
2513 /* peer STA get the LDPC capability from pStaDs, which populated from
2514 * HT/VHT capability*/
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05302515 if(pAddStaParams->vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP)
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002516 {
2517 pAddStaParams->htLdpcCapable = 0;
2518 pAddStaParams->vhtLdpcCapable = 0;
2519 }
2520 else
2521 {
2522 pAddStaParams->htLdpcCapable = pStaDs->htLdpcCapable;
2523 pAddStaParams->vhtLdpcCapable = pStaDs->vhtLdpcCapable;
2524 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002525 }
2526 else if( STA_ENTRY_SELF == pStaDs->staType)
2527 {
2528 /* For Self STA get the LDPC capability from config.ini*/
2529 pAddStaParams->htLdpcCapable =
2530 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2531 pAddStaParams->vhtLdpcCapable =
2532 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2533 }
2534
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 /* Update PE session ID*/
2536 pAddStaParams->sessionId = psessionEntry->peSessionId;
2537
2538 if (psessionEntry->parsedAssocReq != NULL)
2539 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 // Get a copy of the already parsed Assoc Request
2541 pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pStaDs->assocId];
2542 if ( pAssocReq && pAssocReq->addIEPresent && pAssocReq->addIE.length ) {
2543 p2pIe = limGetP2pIEPtr(pMac, pAssocReq->addIE.addIEdata, pAssocReq->addIE.length);
2544 }
2545 pAddStaParams->p2pCapableSta = (p2pIe != NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 }
2547
2548 //Disable BA. It will be set as part of ADDBA negotiation.
2549 for( i = 0; i < STACFG_MAX_TC; i++ )
2550 {
2551 pAddStaParams->staTCParams[i].txUseBA = eBA_DISABLE;
2552 pAddStaParams->staTCParams[i].rxUseBA = eBA_DISABLE;
2553 }
2554
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002555#ifdef FEATURE_WLAN_TDLS
2556 if(pStaDs->wmeEnabled && \
2557 ((eLIM_AP_ROLE == psessionEntry->limSystemRole) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) )
2558#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 if(pStaDs->wmeEnabled && (eLIM_AP_ROLE == psessionEntry->limSystemRole))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 {
2562 pAddStaParams->uAPSD = 0;
2563 /* update UAPSD and send it to LIM to add STA */
2564 // bitmap MSB <- LSB MSB 4 bits are for
2565 // trigger enabled AC setting and LSB 4 bits
2566 // are for delivery enabled AC setting
2567 // 7 6 5 4 3 2 1 0
2568 // BE BK VI VO BE BK VI VO
2569 pAddStaParams->uAPSD |= pStaDs->qos.capability.qosInfo.acvo_uapsd;
2570 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acvi_uapsd << 1);
2571 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbk_uapsd << 2);
2572 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbe_uapsd << 3);
2573 //making delivery enabled and trigger enabled setting the same.
2574 pAddStaParams->uAPSD |= pAddStaParams->uAPSD << 4;
2575
2576 pAddStaParams->maxSPLen = pStaDs->qos.capability.qosInfo.maxSpLen;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302577 limLog( pMac, LOG1, FL("uAPSD = 0x%x, maxSpLen = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 pAddStaParams->uAPSD, pAddStaParams->maxSPLen);
2579 }
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002580
2581#ifdef WLAN_FEATURE_11W
2582 pAddStaParams->rmfEnabled = pStaDs->rmfEnabled;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302583 limLog( pMac, LOG1, FL( "PMF enabled %d"), pAddStaParams->rmfEnabled);
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002584#endif
2585
Abhishek Singh525045c2014-12-15 17:18:45 +05302586 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302587 "p2pCapableSta: %d"), pAddStaParams->htLdpcCapable,
2588 pAddStaParams->vhtLdpcCapable, pAddStaParams->p2pCapableSta);
2589
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002590 //we need to defer the message until we get the response back from HAL.
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 if (pAddStaParams->respReqd)
2592 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002593
2594 msgQ.type = WDA_ADD_STA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595
2596 msgQ.reserved = 0;
2597 msgQ.bodyptr = pAddStaParams;
2598 msgQ.bodyval = 0;
2599
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002600 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ for assocId %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 pStaDs->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002602 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002603
2604 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2605 if( eSIR_SUCCESS != retCode)
2606 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002607 if (pAddStaParams->respReqd)
2608 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002609 limLog( pMac, LOGE, FL("ADD_STA_REQ for aId %d failed (reason %X)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 pStaDs->assocId, retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302611 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 }
2613
2614 return retCode;
2615}
2616
2617
2618/**
2619 * limDelSta()
2620 *
2621 *FUNCTION:
2622 * This function is called to delete an STA context at hardware
2623 * whenever a STA is disassociated
2624 *
2625 *LOGIC:
2626 *
2627 *ASSUMPTIONS:
2628 * NA
2629 *
2630 *NOTE:
2631 * NA
2632 *
2633 * @param pMac - Pointer to Global MAC structure
2634 * @param pStaDs - Pointer to the STA datastructure created by
2635 * LIM and maintained by DPH
2636 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2637 * or not (false)
2638 * @return retCode - Indicates success or failure return code
2639 */
2640
2641tSirRetStatus
2642limDelSta(
2643 tpAniSirGlobal pMac,
2644 tpDphHashNode pStaDs,
2645 tANI_BOOLEAN fRespReqd,
2646 tpPESession psessionEntry)
2647{
2648 tpDeleteStaParams pDelStaParams = NULL;
2649 tSirMsgQ msgQ;
2650 tSirRetStatus retCode = eSIR_SUCCESS;
2651
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302652 pDelStaParams = vos_mem_malloc(sizeof( tDeleteStaParams ));
2653 if (NULL == pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302655 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 return eSIR_MEM_ALLOC_FAILED;
2657 }
2658
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302659 vos_mem_set((tANI_U8 *) pDelStaParams, sizeof(tDeleteStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002660
2661 //
2662 // DPH contains the STA index only for "peer" STA entries.
2663 // LIM global contains "self" STA index
2664 // Thus,
2665 // if( STA role )
2666 // get STA index from LIM global
2667 // else
2668 // get STA index from DPH
2669 //
2670
2671#if 0
2672 /* Since we have not created any STA, no need to send msg to delete
2673 * STA to HAL */
2674 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
2675 pDelStaParams->staIdx = 1; /* TODO : This is workaround. Need to find right STA Index before sending to HAL */
2676 //return retCode;
2677 }
2678#endif
2679
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002680#ifdef FEATURE_WLAN_TDLS
2681 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)) )
2682#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 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 -08002684#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 pDelStaParams->staIdx= psessionEntry->staId;
2686
2687 else
2688 pDelStaParams->staIdx= pStaDs->staIndex;
2689
2690 pDelStaParams->assocId = pStaDs->assocId;
2691 pStaDs->valid = 0;
2692
2693 if (! fRespReqd)
2694 pDelStaParams->respReqd = 0;
2695 else
2696 {
2697 //when limDelSta is called from processSmeAssocCnf then mlmState is already set properly.
2698 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs))
2699 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002700 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs, eLIM_MLM_WT_DEL_STA_RSP_STATE);
2702 }
2703 if ( (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) ||
2704 (eLIM_BT_AMP_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) )
2705 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002706 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002707
2708 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
2709
2710 }
2711 pDelStaParams->respReqd = 1;
2712 //we need to defer the message until we get the response back from HAL.
2713 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2714 }
2715
2716 /* Update PE session ID*/
2717 pDelStaParams->sessionId = psessionEntry->peSessionId;
2718
2719 pDelStaParams->status = eHAL_STATUS_SUCCESS;
2720 msgQ.type = WDA_DELETE_STA_REQ;
2721 msgQ.reserved = 0;
2722 msgQ.bodyptr = pDelStaParams;
2723 msgQ.bodyval = 0;
2724
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302725 limLog( pMac, LOG1, FL( "Sessionid %d :Sending SIR_HAL_DELETE_STA_REQ "
2726 "for STAID: %X and AssocID: %d MAC : "MAC_ADDRESS_STR ),
2727 pDelStaParams->sessionId,
2728 pDelStaParams->staIdx, pDelStaParams->assocId,
2729 MAC_ADDR_ARRAY(pStaDs->staAddr));
2730
Jeff Johnsone7245742012-09-05 17:12:55 -07002731 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2733 if( eSIR_SUCCESS != retCode)
2734 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002735 if(fRespReqd)
2736 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002737 limLog( pMac, LOGE, FL("Posting DELETE_STA_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302739 vos_mem_free(pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 }
2741
2742 return retCode;
2743}
2744
2745#if defined WLAN_FEATURE_VOWIFI_11R
2746/*------------------------------------------------------------------------
2747 * limAddFTStaSelf()
2748 *
2749 * FUNCTION:
2750 *
2751 * This function is called to add a STA once we have connected with a new
2752 * AP, that we have performed an FT to.
2753 *
2754 * The Add STA Response is created and now after the ADD Bss Is Successful
2755 * we add the self sta. We update with the association id from the reassoc
2756 * response from the AP.
2757 *------------------------------------------------------------------------
2758 */
2759tSirRetStatus limAddFTStaSelf(tpAniSirGlobal pMac, tANI_U16 assocId, tpPESession psessionEntry)
2760{
2761 tpAddStaParams pAddStaParams = NULL;
2762 tSirMsgQ msgQ;
2763 tSirRetStatus retCode = eSIR_SUCCESS;
2764
2765 pAddStaParams = pMac->ft.ftPEContext.pAddStaReq;
2766 pAddStaParams->assocId = assocId;
2767
2768 msgQ.type = SIR_HAL_ADD_STA_REQ;
2769 msgQ.reserved = 0;
2770 msgQ.bodyptr = pAddStaParams;
2771 msgQ.bodyval = 0;
2772
2773
2774#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002775 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ), pAddStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002776#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002777 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002778
2779 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002780 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2782 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2783 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002784 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302785 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 }
2787 //
2788 // Dont need it any more
2789 pMac->ft.ftPEContext.pAddStaReq = NULL;
2790 return retCode;
2791}
2792
2793#endif /* WLAN_FEATURE_VOWIFI_11R */
2794
2795/**
2796 * limAddStaSelf()
2797 *
2798 *FUNCTION:
2799 * This function is called to add an STA context at hardware
2800 * whenever a STA is (Re) Associated.
2801 *
2802 *LOGIC:
2803 *
2804 *ASSUMPTIONS:
2805 * NA
2806 *
2807 *NOTE:
2808 * NA
2809 *
2810 * @param pMac - Pointer to Global MAC structure
2811 * @param pStaDs - Pointer to the STA datastructure created by
2812 * LIM and maintained by DPH
2813 * @return retCode - Indicates success or failure return code
2814 */
2815
2816tSirRetStatus
2817limAddStaSelf(tpAniSirGlobal pMac,tANI_U16 staIdx, tANI_U8 updateSta, tpPESession psessionEntry)
2818{
2819 tpAddStaParams pAddStaParams = NULL;
2820 tSirMsgQ msgQ;
2821 tSirRetStatus retCode = eSIR_SUCCESS;
2822 tSirMacAddr staMac;
2823 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
krunal soni71343fb2013-09-16 16:16:26 -07002824 tANI_U32 shortGi20MhzSupport;
2825 tANI_U32 shortGi40MhzSupport;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302826 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002827 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2828 * that cfg carries the systemwide capability that device under
2829 * consideration can support. This capability gets plumbed into the cfg
2830 * cache at system initialization time via the .dat and .ini file override
2831 * mechanisms and will not change. If it does change, it is the
2832 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2833 * command.*/
2834 tANI_U32 selfStaDot11Mode=0, selfTxWidth=0;
2835 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
2836 limLog( pMac, LOG1, FL("cfgDot11Mode %d"),(int)selfStaDot11Mode);
2837 wlan_cfgGetInt(pMac,WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,&selfTxWidth);
2838 limLog( pMac, LOG1, FL("SGI 20 %d"),(int)selfTxWidth);
2839 limLog( pMac, LOG1, FL("Roam Channel Bonding Mode %d"),(int)pMac->roam.configParam.uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002840
2841 #if 0
2842 retCode =wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2843 if (retCode != eSIR_SUCCESS)
2844 {
2845 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002846 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 return retCode;
2848 }
2849 #endif //TO SUPPORT BT-AMP
2850 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302851 limLog(pMac, LOG1, FL(MAC_ADDRESS_STR": "),MAC_ADDR_ARRAY(staMac));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302852 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2853 if (NULL == pAddStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302855 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 return eSIR_MEM_ALLOC_FAILED;
2857 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302858 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002859
2860 /// Add STA context at MAC HW (BMU, RHP & TFP)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302861 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2862 (tANI_U8 *) staMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002863
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302864 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2865 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002866
2867 pAddStaParams->assocId = psessionEntry->limAID;
2868 pAddStaParams->staType = STA_ENTRY_SELF;
2869 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2870 pAddStaParams->respReqd = 1;
Abhishek Singhf08a82b2014-10-07 11:00:42 +05302871 pAddStaParams->currentOperChan = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 /* Update PE session ID */
2873 pAddStaParams->sessionId = psessionEntry->peSessionId;
2874
2875 // This will indicate HAL to "allocate" a new STA index
2876 pAddStaParams->staIdx = staIdx;
2877 pAddStaParams->updateSta = updateSta;
2878
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05302879 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
2880 {
2881 limLog(pMac, LOGP, FL("Get short preamble failed. Set Default value"));
2882 pAddStaParams->shortPreambleSupported = 1;
2883 }
2884 pAddStaParams->shortPreambleSupported = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002885
Jeff Johnsone7245742012-09-05 17:12:55 -07002886#ifdef WLAN_FEATURE_11AC
2887 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry,NULL);
2888#else
2889 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
2890#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002891// if( psessionEntry->htCapability)---> old check
2892 /*We used to check if the session is htCapable before setting the htCapable
2893 * flag. The check limited us from operating */
2894 if ( IS_DOT11_MODE_HT(selfStaDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002896 pAddStaParams->htCapable = TRUE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002897#ifdef DISABLE_GF_FOR_INTEROP
2898 /*
2899 * To resolve the interop problem with Broadcom AP,
2900 * where TQ STA could not pass traffic with GF enabled,
2901 * TQ STA will do Greenfield only with TQ AP, for
2902 * everybody else it will be turned off.
2903 */
2904 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2905 {
2906 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2907 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2908 }
2909 else
2910#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002911 {
2912 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
2913 pAddStaParams->txChannelWidthSet =
2914 pMac->roam.configParam.channelBondingMode5GHz;
2915 // pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
2916 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
2917 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
2918 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
2919 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
2920 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
2921 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
2922 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
2923 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
krunal soni71343fb2013-09-16 16:16:26 -07002924 /*
2925 * We will read the gShortGI20Mhz from ini file, and if it is set
2926 * to 1 then we will tell Peer that we support 40Mhz short GI
2927 */
2928 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
2929 (pMac, WNI_CFG_SHORT_GI_20MHZ,
2930 &shortGi20MhzSupport)))
2931 {
2932 if (VOS_TRUE == shortGi20MhzSupport)
2933 {
2934 pAddStaParams->fShortGI20Mhz =
2935 WNI_CFG_SHORT_GI_20MHZ_STAMAX;
2936 //pAddStaParams->fShortGI20Mhz =
2937 //limGetHTCapability(pMac, eHT_SHORT_GI_20MHZ,
2938 // psessionEntry);
2939 }
2940 else
2941 {
2942 pAddStaParams->fShortGI20Mhz = VOS_FALSE;
2943 }
2944 }
2945 else
2946 {
2947 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
2948 "CFG,setting value to default"));)
2949 pAddStaParams->fShortGI20Mhz = WNI_CFG_SHORT_GI_20MHZ_STADEF;
2950 }
2951
2952 /*
2953 * We will read the gShortGI40Mhz from ini file, and if it is set
2954 * to 1 then we will tell Peer that we support 40Mhz short GI
2955 */
2956 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
2957 (pMac, WNI_CFG_SHORT_GI_40MHZ,
2958 &shortGi40MhzSupport)))
2959 {
2960 if (VOS_TRUE == shortGi40MhzSupport)
2961 {
2962 pAddStaParams->fShortGI40Mhz =
2963 WNI_CFG_SHORT_GI_40MHZ_STAMAX;
2964 //pAddStaParams->fShortGI40Mhz =
2965 //limGetHTCapability(pMac, eHT_SHORT_GI_40MHZ,
2966 // psessionEntry);
2967 }
2968 else
2969 {
2970 pAddStaParams->fShortGI40Mhz = VOS_FALSE;
2971 }
2972 }
2973 else
2974 {
2975 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
2976 "CFG,setting value to default"));)
2977 pAddStaParams->fShortGI40Mhz = WNI_CFG_SHORT_GI_40MHZ_STADEF;
2978 }
Abhishek Singh525045c2014-12-15 17:18:45 +05302979 limLog(pMac, LOG1, FL(" greenFieldCapable: %d maxAmpduDensity = %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302980 "maxAmpduSize = %d"), pAddStaParams->greenFieldCapable,
2981 pAddStaParams->maxAmpduDensity, pAddStaParams->maxAmpduSize);
2982
Abhishek Singh525045c2014-12-15 17:18:45 +05302983 limLog(pMac, LOG1, FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302984 "fShortGI40Mhz: %d lsigTxopProtection: %d"),
2985 pAddStaParams->fDsssCckMode40Mhz, pAddStaParams->fShortGI20Mhz,
2986 pAddStaParams->fShortGI40Mhz, pAddStaParams->lsigTxopProtection);
2987
Abhishek Singh525045c2014-12-15 17:18:45 +05302988 limLog(pMac, LOG1, FL(" maxAmsduSize: %d txChannelWidthSet: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05302989 "mimoPS: %d rifsMode %d delBASupport %d"),
2990 pAddStaParams->maxAmsduSize,
2991 pAddStaParams->txChannelWidthSet, pAddStaParams->mimoPS,
2992 pAddStaParams->rifsMode, pAddStaParams->delBASupport );
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002995#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002996 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
2997 if (pAddStaParams->vhtCapable){
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002998 pAddStaParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002999 limLog( pMac, LOG1, FL("VHT WIDTH SET %d"),pAddStaParams->vhtTxChannelWidthSet);
3000 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08003001 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Abhishek Singh525045c2014-12-15 17:18:45 +05303002 limLog(pMac, LOG1, FL("vhtCapable: %d vhtTxBFCapable %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303003 pAddStaParams->vhtCapable, pAddStaParams->vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003004#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003005
3006 /* For Self STA get the LDPC capability from session i.e config.ini*/
3007 pAddStaParams->htLdpcCapable =
3008 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
3009 pAddStaParams->vhtLdpcCapable =
3010 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
3011
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003013 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
3015
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3017 {
3018 pAddStaParams->p2pCapableSta = 1;
3019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003020
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003021 //limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
3022 pAddStaParams->supportedRates.opRateMode = limGetStaRateMode((tANI_U8)selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003023
Abhishek Singh525045c2014-12-15 17:18:45 +05303024 limLog(pMac, LOG1, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303025 pAddStaParams->staIdx,pAddStaParams->updateSta,
3026 pAddStaParams->htCapable);
3027
Abhishek Singh525045c2014-12-15 17:18:45 +05303028 limLog(pMac, LOG1, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303029 "p2pCapableSta: %d"),
3030 pAddStaParams->htLdpcCapable,pAddStaParams->vhtLdpcCapable,
3031 pAddStaParams->p2pCapableSta);
3032
Abhishek Singh525045c2014-12-15 17:18:45 +05303033 limLog(pMac, LOG1, FL(" sessionid: %d Assoc ID: %d listenInterval = %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303034 " shortPreambleSupported: %d "), psessionEntry->smeSessionId,
3035 pAddStaParams->assocId, pAddStaParams->listenInterval,
3036 pAddStaParams->shortPreambleSupported);
3037
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 msgQ.type = WDA_ADD_STA_REQ;
3039 //
3040 // FIXME_GEN4
3041 // A global counter (dialog token) is required to keep track of
3042 // all PE <-> HAL communication(s)
3043 //
3044 msgQ.reserved = 0;
3045 msgQ.bodyptr = pAddStaParams;
3046 msgQ.bodyval = 0;
3047
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303048 limLog( pMac, LOGW, FL(MAC_ADDRESS_STR":Sessionid %d : "
3049 "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ),
3050 MAC_ADDR_ARRAY(pAddStaParams->staMac),
3051 pAddStaParams->sessionId,
3052 pAddStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07003053 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003054
3055 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3056 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003057 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303058 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 }
3060 return retCode;
3061}
3062
3063
3064/**
3065 * limTeardownInfraBSS()
3066 *
3067 *FUNCTION:
3068 * This function is called by various LIM functions to teardown
3069 * an established Infrastructure BSS
3070 *
3071 *LOGIC:
3072 *
3073 *ASSUMPTIONS:
3074 *
3075 *NOTE:
3076 *
3077 * @param pMac - Pointer to Global MAC structure
3078 * @return None
3079 */
3080
3081void
3082limTeardownInfraBss(tpAniSirGlobal pMac,tpPESession psessionEntry)
3083{
3084 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3085
3086 /**
3087 * Send Broadcast Disassociate frame with
3088 * 'leaving BSS' reason.
3089 */
3090 limSendDisassocMgmtFrame(pMac,
3091 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003092 bcAddr,psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003093} /*** end limTeardownInfraBss() ***/
3094
3095
3096/**
3097 * limHandleCnfWaitTimeout()
3098 *
3099 *FUNCTION:
3100 * This function is called by limProcessMessageQueue to handle
3101 * various confirmation failure cases.
3102 *
3103 *LOGIC:
3104 *
3105 *ASSUMPTIONS:
3106 *
3107 *NOTE:
3108 *
3109 * @param pMac - Pointer to Global MAC structure
3110 * @param pStaDs - Pointer to a sta descriptor
3111 * @return None
3112 */
3113
3114void limHandleCnfWaitTimeout(tpAniSirGlobal pMac, tANI_U16 staId)
3115{
3116 tpDphHashNode pStaDs;
3117 tLimSystemRole systemRole;
3118 tpPESession psessionEntry = NULL;
3119
3120 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId))== NULL)
3121 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003122 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 return;
3124 }
3125 systemRole = limGetSystemRole(psessionEntry);
3126 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
3127
3128 if (pStaDs == NULL)
3129 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003130 PELOGW(limLog(pMac, LOGW, FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 return;
3132 }
3133
3134 switch (pStaDs->mlmStaContext.mlmState) {
3135 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003136 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 -07003137 limPrintMacAddr(pMac, pStaDs->staAddr, LOGW);
3138
3139 if ( (systemRole == eLIM_AP_ROLE)|| (systemRole == eLIM_BT_AMP_AP_ROLE) )
3140 {
3141 limRejectAssociation(
3142 pMac,
3143 pStaDs->staAddr,
3144 pStaDs->mlmStaContext.subType,
3145 true,
3146 pStaDs->mlmStaContext.authType,
3147 pStaDs->assocId,
3148 true,
3149 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
3150 psessionEntry);
3151 }
3152 break;
3153
3154 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003155 limLog(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 pStaDs->mlmStaContext.mlmState);
3157 }
3158}
3159
3160
3161/**
3162 * limDeleteDphHashEntry()
3163 *
3164 *FUNCTION:
3165 * This function is called whenever we need to delete
3166 * the dph hash entry
3167 *
3168 *LOGIC:
3169 *
3170 *ASSUMPTIONS:
3171 *
3172 *NOTE:
3173 *
3174 * @param pMac Pointer to Global MAC structure
3175 * @param tANI_U16 staId
3176 * @return None
3177 */
3178
3179void
3180limDeleteDphHashEntry(tpAniSirGlobal pMac, tSirMacAddr staAddr, tANI_U16 staId,tpPESession psessionEntry)
3181{
3182 tANI_U16 aid;
3183 tpDphHashNode pStaDs;
3184 tUpdateBeaconParams beaconParams;
3185 tLimSystemRole systemRole;
3186
Kaushik, Sushantfb156732014-01-07 15:36:03 +05303187 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 beaconParams.paramChangeBitmap = 0;
3189 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, staId);
3190 if (NULL == psessionEntry)
3191 {
3192 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
3193 return;
3194 }
3195 systemRole = limGetSystemRole(psessionEntry);
3196 beaconParams.bssIdx = psessionEntry->bssIdx;
3197 pStaDs = dphLookupHashEntry(pMac, staAddr, &aid, &psessionEntry->dph.dphHashTable);
3198 if (pStaDs != NULL)
3199 {
3200 PELOGW(limLog(pMac, LOGW, FL("Deleting DPH Hash entry for STAID: %X\n "), staId);)
3201 // update the station count and perform associated actions
3202 // do this before deleting the dph hash entry
3203 limUtilCountStaDel(pMac, pStaDs, psessionEntry);
3204
3205 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||
3206 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
3207 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
3209 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE){
3210 limDecideApProtectionOnDelete(pMac, pStaDs, &beaconParams,psessionEntry);
3211 }
3212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003213
3214 if(eLIM_STA_IN_IBSS_ROLE == systemRole)
3215 limIbssDecideProtectionOnDelete(pMac, pStaDs, &beaconParams, psessionEntry);
3216
3217 limDecideShortPreamble(pMac, pStaDs, &beaconParams, psessionEntry);
3218 limDecideShortSlot(pMac, pStaDs, &beaconParams, psessionEntry);
3219
3220 //Send message to HAL about beacon parameter change.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003221 PELOGW(limLog(pMac, LOGW, FL("param bitmap = %d "), beaconParams.paramChangeBitmap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 if(beaconParams.paramChangeBitmap)
3223 {
3224 schSetFixedBeaconFields(pMac,psessionEntry);
3225 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
3226 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08003227
3228#ifdef WLAN_FEATURE_11W
3229 tx_timer_delete(&pStaDs->pmfSaQueryTimer);
3230#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 }
3232 if (dphDeleteHashEntry(pMac, staAddr, staId, &psessionEntry->dph.dphHashTable) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003233 limLog(pMac, LOGP, FL("error deleting hash entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 }
3235}
3236
3237
3238
3239/**
3240 * limCheckAndAnnounceJoinSuccess()
3241 *
3242 *FUNCTION:
3243 * This function is called upon receiving Beacon/Probe Response
3244 * frame in WT_JOIN_BEACON_STATE to check if the received
3245 * Beacon/Probe Response is from the BSS that we're attempting
3246 * to join.
3247 *
3248 *LOGIC:
3249 * If the Beacon/Probe Response is indeed from the BSS we're
3250 * attempting to join, join success is sent to SME.
3251 *
3252 *ASSUMPTIONS:
3253 *
3254 *NOTE:
3255 *
3256 * @param pMac Pointer to Global MAC structure
3257 * @param pBPR Pointer to received Beacon/Probe Response
3258 * @param pHdr Pointer to received Beacon/Probe Response
3259 * MAC header
3260 * @return None
3261 */
3262
3263void
3264limCheckAndAnnounceJoinSuccess(tpAniSirGlobal pMac,
3265 tSirProbeRespBeacon *pBPR,
3266 tpSirMacMgmtHdr pHdr,tpPESession psessionEntry)
3267{
3268 tSirMacSSid currentSSID;
3269 tLimMlmJoinCnf mlmJoinCnf;
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003270 tANI_U32 val = 0;
3271 tANI_U32 *noa1DurationFromBcn = NULL;
3272 tANI_U32 *noa2DurationFromBcn = NULL;
3273 tANI_U32 noa;
3274 tANI_U32 TotalNum_NoADesc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003275
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303276 vos_mem_copy(currentSSID.ssId,
3277 psessionEntry->ssId.ssId,
3278 psessionEntry->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003279
3280 currentSSID.length = (tANI_U8)psessionEntry->ssId.length ;
3281
3282 if (
3283 /* Check for SSID only in probe response. Beacons may not carry
3284 SSID information in hidden SSID case */
3285 ( (SIR_MAC_MGMT_FRAME == pHdr->fc.type) &&
3286 (SIR_MAC_MGMT_PROBE_RSP == pHdr->fc.subType) ) &&
3287 currentSSID.length &&
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303288 (!vos_mem_compare((tANI_U8 *) &pBPR->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 (tANI_U8 *) &currentSSID,
3290 (tANI_U8) (1 + currentSSID.length)) ))
3291 {
3292 /**
3293 * Received SSID does not match with the one we've.
3294 * Ignore received Beacon frame
3295 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303296 limLog(pMac, LOG1, FL("SSID received in Beacon does not match"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003297#ifdef WLAN_DEBUG
3298 pMac->lim.gLimBcnSSIDMismatchCnt++;
3299#endif
3300 return;
3301 }
3302
3303 if( (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_STA_ROLE))
3304 {
Nirav Shahbc35fb72013-12-12 18:14:06 +05303305 limLog(pMac, LOG1, FL("Received Beacon/PR with matching BSSID"
3306 MAC_ADDRESS_STR "PESessionID %d"),
3307 MAC_ADDR_ARRAY(psessionEntry->bssId),
3308 psessionEntry->peSessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 // Deactivate Join Failure timer
3310 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003311 // Deactivate Periodic Join timer
3312 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07003313
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003314 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona &&
3315 pBPR->P2PProbeRes.NoticeOfAbsence.present)
3316 {
3317
3318 noa1DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3319
3320 if(pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3321 TotalNum_NoADesc = pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc/SIZE_OF_NOA_DESCRIPTOR;
3322
3323 noa = *noa1DurationFromBcn;
3324
3325 if(TotalNum_NoADesc > 1)
3326 {
3327 noa2DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + SIZE_OF_NOA_DESCRIPTOR + 1);
3328 noa += *noa2DurationFromBcn;
3329 }
3330
3331 /*If MAX Noa exceeds 3 secs we will consider only 3 secs to
3332 * avoid arbitary values in noa duration field
3333 */
3334 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ? MAX_NOA_PERIOD_IN_MICROSECS : noa;
3335 noa = noa/1000; //Convert to ms
3336
3337 if( wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,&val) == eSIR_SUCCESS )
3338 {
3339 psessionEntry->defaultAuthFailureTimeout = val;
3340 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,val + noa, NULL, eANI_BOOLEAN_FALSE);
3341 }
3342 }
3343 else
3344 {
3345 psessionEntry->defaultAuthFailureTimeout = 0;
3346 }
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 // Update Beacon Interval at CFG database
3349
3350 if ( pBPR->HTCaps.present )
3351 limUpdateStaRunTimeHTCapability( pMac, &pBPR->HTCaps );
3352 if ( pBPR->HTInfo.present )
3353 limUpdateStaRunTimeHTInfo( pMac, &pBPR->HTInfo, psessionEntry);
3354 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003355 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003356
Ganesh Kondabattiniaad38d92014-11-19 17:06:00 +05303357 /* update the capability info based on recently
3358 * received beacon/probe response frame */
3359 psessionEntry->limCurrentBssCaps = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360
3361 /**
3362 * Announce join success by sending
3363 * Join confirm to SME.
3364 */
3365 mlmJoinCnf.resultCode = eSIR_SME_SUCCESS;
3366 mlmJoinCnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3367 /* Update PE sessionId*/
3368 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3369 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3370 } // if ((pMac->lim.gLimSystemRole == IBSS....
3371}
3372
3373/**
3374 * limExtractApCapabilities()
3375 *
3376 *FUNCTION:
3377 * This function is called to extract all of the AP's capabilities
3378 * from the IEs received from it in Beacon/Probe Response frames
3379 *
3380 *LOGIC:
3381 * This routine mimics the limExtractApCapability() API. The difference here
3382 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3383 * left to the caller of this API to use this info as required
3384 *
3385 *ASSUMPTIONS:
3386 * NA
3387 *
3388 *NOTE:
3389 *
3390 * @param pMac Pointer to Global MAC structure
3391 * @param pIE Pointer to starting IE in Beacon/Probe Response
3392 * @param ieLen Length of all IEs combined
3393 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3394 * populated
3395 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3396 */
3397tSirRetStatus limExtractApCapabilities( tpAniSirGlobal pMac,
3398 tANI_U8 *pIE,
3399 tANI_U16 ieLen,
3400 tpSirProbeRespBeacon beaconStruct )
3401{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303402 vos_mem_set((tANI_U8 *) beaconStruct, sizeof( tSirProbeRespBeacon ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003403
3404 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003405 FL( "In limExtractApCapabilities: The IE's being received are:" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
3407
3408 // Parse the Beacon IE's, Don't try to parse if we dont have anything in IE
3409 if (ieLen > 0) {
3410 if( eSIR_SUCCESS != sirParseBeaconIE( pMac, beaconStruct, pIE, (tANI_U32)ieLen ))
3411 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003412 limLog( pMac, LOGE, FL("APCapExtract: Beacon parsing error!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 return eSIR_FAILURE;
3414 }
3415 }
3416
3417 return eSIR_SUCCESS;
3418}
3419
3420
3421/**
3422 * limDelBss()
3423 *
3424 *FUNCTION:
3425 * This function is called to delete BSS context at hardware
3426 * whenever a STA is disassociated
3427 *
3428 *LOGIC:
3429 *
3430 *ASSUMPTIONS:
3431 * NA
3432 *
3433 *NOTE:
3434 * NA
3435 *
3436 * @param pMac - Pointer to Global MAC structure
3437 * @param pStaDs - Pointer to the STA datastructure created by
3438 * LIM and maintained by DPH
3439 * @return retCode - Indicates success or failure return code
3440 */
3441
3442tSirRetStatus
3443limDelBss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tANI_U16 bssIdx,tpPESession psessionEntry)
3444{
3445 tpDeleteBssParams pDelBssParams = NULL;
3446 tSirMsgQ msgQ;
3447 tSirRetStatus retCode = eSIR_SUCCESS;
3448
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303449 pDelBssParams = vos_mem_malloc(sizeof(tDeleteBssParams));
3450 if (NULL == pDelBssParams)
3451 {
3452 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 return eSIR_MEM_ALLOC_FAILED;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303454 }
3455 vos_mem_set((tANI_U8 *) pDelBssParams, sizeof(tDeleteBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003456
3457
3458 pDelBssParams->sessionId = psessionEntry->peSessionId; //update PE session Id
3459
3460 //DPH was storing the AssocID in staID field,
3461 //staID is actually assigned by HAL when AddSTA message is sent.
3462 if (pStaDs != NULL)
3463 {
3464 pDelBssParams->bssIdx= pStaDs->bssId;
3465 pStaDs->valid = 0;
3466 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3467 }
3468 else
3469 pDelBssParams->bssIdx = bssIdx;
3470 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003471 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003472
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07003473 if((psessionEntry->peSessionId == pMac->lim.limTimers.gLimJoinFailureTimer.sessionId) &&
3474 (VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)))
3475 {
3476 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
3477 }
3478
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 pDelBssParams->status= eHAL_STATUS_SUCCESS;
3480 pDelBssParams->respReqd = 1;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303481
3482 PELOGW(limLog( pMac, LOGW, FL("Sessionid %d : Sending HAL_DELETE_BSS_REQ "
3483 "for bss idx: %X BSSID:"MAC_ADDRESS_STR), pDelBssParams->sessionId,
3484 pDelBssParams->bssIdx,
3485 MAC_ADDR_ARRAY(psessionEntry->bssId));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003486
3487 //we need to defer the message until we get the response back from HAL.
3488 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3489
3490 msgQ.type = WDA_DELETE_BSS_REQ;
3491 msgQ.reserved = 0;
3492 msgQ.bodyptr = pDelBssParams;
3493 msgQ.bodyval = 0;
3494
Jeff Johnsone7245742012-09-05 17:12:55 -07003495 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003496
3497 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3498 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003499 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003500 limLog( pMac, LOGE, FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303501 vos_mem_free(pDelBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 }
3503
3504 return retCode;
3505}
3506
3507
Jeff Johnson295189b2012-06-20 16:38:30 -07003508
3509/**
3510 * limSendAddBss()
3511 *
3512 *FUNCTION:
3513 *
3514 *LOGIC:
3515 * 1) LIM receives eWNI_SME_JOIN_REQ
3516 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3517 * SIR_HAL_ADD_BSS_REQ to HAL
3518 *
3519 *ASSUMPTIONS:
3520 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3521 * ADD BSS parameters can be obtained from two sources:
3522 * 1) pMac->lim.gLimMlmJoinReq
3523 * 2) beaconStruct, passed as paramter
3524 * So, if a reqd parameter is found in bssDescriptions
3525 * then it is given preference over beaconStruct
3526 *
3527 *NOTE:
3528 *
3529 * @param pMac Pointer to Global MAC structure
3530 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3531 * beaconstruct Has the ProbeRsp/Beacon structured details
3532 * bssDescription bssDescription passed to PE from the SME
3533 * @return None
3534 */
3535
3536tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3537 tpSchBeaconStruct pBeaconStruct, tpSirBssDescription bssDescription, tANI_U8 updateEntry,
3538 tpPESession psessionEntry)
3539
3540{
3541 tSirMsgQ msgQ;
3542 tpAddBssParams pAddBssParams = NULL;
3543 tANI_U32 retCode;
3544 tANI_U8 i;
3545 tpDphHashNode pStaDs = NULL;
3546 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003547 tANI_U32 shortGi20MhzSupport;
3548 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303550 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
3551 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 {
3553 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303554 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 retCode = eSIR_MEM_ALLOC_FAILED;
3556 goto returnFailure;
3557 }
3558 else
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303559 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003560
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303561 vos_mem_copy(pAddBssParams->bssId,bssDescription->bssId,
3562 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303564 vos_mem_copy(pAddBssParams->selfMacAddr,
3565 psessionEntry->selfMacAddr,
3566 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303567
3568 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
3569 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
3570
3571 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
3572 MAC_ADDR_ARRAY(pAddBssParams->bssId));
3573
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3575 {
3576 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3577 }
3578 else
3579 {
3580 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3581 }
3582
3583 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3584
3585 /* Update PE session ID */
3586 pAddBssParams->sessionId = psessionEntry->peSessionId;
3587
3588 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3589
3590 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3591 pAddBssParams->updateBss = updateEntry;
3592
3593
3594 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3595 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3596 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3597 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
3598
3599 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303600 vos_mem_copy(pAddBssParams->rateSet.rate,
3601 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003602
3603 pAddBssParams->nwType = bssDescription->nwType;
3604
Jeff Johnsone7245742012-09-05 17:12:55 -07003605 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3607 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3608 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3609 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3610
Abhishek Singh525045c2014-12-15 17:18:45 +05303611 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303612 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
3613 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
3614
Abhishek Singh525045c2014-12-15 17:18:45 +05303615 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303616 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
3617 pAddBssParams->cfParamSet.cfpMaxDuration,
3618 pAddBssParams->cfParamSet.cfpDurRemaining,
3619 pAddBssParams->rateSet.numRates);
3620
Abhishek Singh525045c2014-12-15 17:18:45 +05303621 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303622 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
3623 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
3624 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
3625 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07003626
3627 // Use the advertised capabilities from the received beacon/PR
3628
3629
3630 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3631 {
3632 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05303633 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 if ( pBeaconStruct->HTInfo.present )
3635 {
3636 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pAssocRsp->HTInfo.opMode;
3637 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pAssocRsp->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3640 (chanWidthSupp) )
3641 {
3642 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3643 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3644 }
3645 else
3646 {
3647 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003648 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 }
3650 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3651 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3652 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303653
Abhishek Singh525045c2014-12-15 17:18:45 +05303654 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303655 "txChannelWidthSet: %d currentExtChannel: %d "),
3656 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
3657 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
3658
Abhishek Singh525045c2014-12-15 17:18:45 +05303659 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303660 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
3661 pAddBssParams->llnNonGFCoexist,
3662 pAddBssParams->fLsigTXOPProtectionFullSupport,
3663 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 }
3665 }
3666
3667 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05303668 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303669 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003670#ifdef WLAN_FEATURE_11AC
3671 if (psessionEntry->vhtCapability && ( pAssocRsp->VHTCaps.present ))
3672 {
3673 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3674 pAddBssParams->vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth;
3675 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003676 pAddBssParams->currentOperChannel,
3677 pAddBssParams->currentExtChannel,
3678 psessionEntry->apCenterChan,
3679 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003680 }
3681 else
3682 {
3683 pAddBssParams->vhtCapable = 0;
3684 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303685 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303686 "currentExtChannel %d"),pAddBssParams->vhtCapable,
3687 pAddBssParams->vhtTxChannelWidthSet,
3688 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07003689#endif
3690
3691
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 // Populate the STA-related parameters here
3693 // Note that the STA here refers to the AP
3694 {
3695 /* staType = PEER*/
3696 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3697
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303698 vos_mem_copy(pAddBssParams->staContext.bssId,
3699 bssDescription->bssId,
3700 sizeof( tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3702
3703 /* Fill Assoc id from the dph table */
3704 pStaDs = dphLookupHashEntry(pMac, pAddBssParams->staContext.bssId,
3705 &pAddBssParams->staContext.assocId, &psessionEntry->dph.dphHashTable);
3706 if (pStaDs == NULL)
3707 {
Arif Hussain24bafea2013-11-15 15:10:03 -08003708 PELOGE(limLog(pMac, LOGE, FL("Couldn't get assoc id for "
3709 "MAC ADDR: " MAC_ADDRESS_STR),
3710 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 }
3712 pAddBssParams->staContext.uAPSD = 0;
3713 pAddBssParams->staContext.maxSPLen = 0;
Sushant Kaushikb90b4e22015-04-14 14:29:49 +05303714 pAddBssParams->staContext.shortPreambleSupported =
3715 psessionEntry->beaconParams.fShortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 pAddBssParams->staContext.updateSta = updateEntry;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303717
Abhishek Singh525045c2014-12-15 17:18:45 +05303718 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303719 " shortPreambleSupported: %d"),
3720 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
3721 pAddBssParams->staContext.shortPreambleSupported);
3722
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003723 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 {
3725 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3726 pAddBssParams->staContext.htCapable = 1;
3727 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3728 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05303729 limLog(pMac, LOG1,FL("StaContext htCapable: %d greenFieldCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303730 "lsigTxopProtection: %d"), pAddBssParams->staContext.htCapable,
3731 pAddBssParams->staContext.greenFieldCapable,
3732 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003733#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05303734 if (psessionEntry->vhtCapability &&
3735 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003736 {
3737 pAddBssParams->staContext.vhtCapable = 1;
3738 if ((pAssocRsp->VHTCaps.suBeamFormerCap ||
3739 pAssocRsp->VHTCaps.muBeamformerCap) &&
3740 psessionEntry->txBFIniFeatureEnabled)
3741 {
3742 pAddBssParams->staContext.vhtTxBFCapable = 1;
3743 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303744 if (pAssocRsp->VHTCaps.muBeamformerCap &&
3745 psessionEntry->txMuBformee )
3746 {
3747 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
3748 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
3749 /* Dont allow any other MuBf session as concurrency
3750 * is not supported
3751 */
3752 pMac->isMuBfsessionexist = TRUE;
3753 }
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003754 }
3755#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3757 (chanWidthSupp) )
3758 {
3759 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003760#ifdef WLAN_FEATURE_11AC
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003761 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003762 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003763 pAddBssParams->staContext.vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth; //pMac->lim.apChanWidth;
3764 }
Abhishek Singh525045c2014-12-15 17:18:45 +05303765 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303766 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
3767 pAddBssParams->staContext.vhtCapable,
3768 pAddBssParams->staContext.vhtTxChannelWidthSet,
3769 pAddBssParams->staContext.vhtTxBFCapable);
Jeff Johnsone7245742012-09-05 17:12:55 -07003770#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 }
3772 else
3773 {
3774 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3775 }
3776 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pAssocRsp->HTCaps.mimoPowerSave;
3777 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3778 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3779 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3780 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003781 /*
3782 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3783 * if they are set then we will use what ever Assoc response coming
3784 * from AP supports. If these values are set as 0 in ini file then
3785 * we will hardcode this values to 0.
3786 */
3787 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3788 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3789 &shortGi20MhzSupport)))
3790 {
3791 if (VOS_TRUE == shortGi20MhzSupport)
3792 {
3793 pAddBssParams->staContext.fShortGI20Mhz =
3794 (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3795 }
3796 else
3797 {
3798 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3799 }
3800 }
3801 else
3802 {
3803 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3804 "CFG,setting value to default"));)
3805 pAddBssParams->staContext.fShortGI20Mhz =
3806 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3807 }
3808
3809 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3810 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3811 &shortGi40MhzSupport)))
3812 {
3813 if (VOS_TRUE == shortGi40MhzSupport)
3814 {
3815 pAddBssParams->staContext.fShortGI40Mhz =
3816 (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3817 }
3818 else
3819 {
3820 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3821 }
3822 }
3823 else
3824 {
3825 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3826 "CFG,setting value to default"));)
3827 pAddBssParams->staContext.fShortGI40Mhz =
3828 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3829 }
3830
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05303832 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003833 {
3834 pAddBssParams->staContext.htLdpcCapable = 0;
3835 pAddBssParams->staContext.vhtLdpcCapable = 0;
3836 }
3837 else
3838 {
3839 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pAssocRsp->HTCaps.advCodingCap;
3840 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pAssocRsp->VHTCaps.ldpcCodingCap;
3841 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003842
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 if( pBeaconStruct->HTInfo.present )
3844 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303845
Abhishek Singh525045c2014-12-15 17:18:45 +05303846 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303847 " delBASupport: %d maxAmsduSize: %d"),
3848 pAddBssParams->staContext.txChannelWidthSet,
3849 pAddBssParams->staContext.mimoPS,
3850 pAddBssParams->staContext.delBASupport,
3851 pAddBssParams->staContext.maxAmsduSize);
3852
Abhishek Singh525045c2014-12-15 17:18:45 +05303853 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303854 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
3855 pAddBssParams->staContext.fDsssCckMode40Mhz,
3856 pAddBssParams->staContext.fShortGI20Mhz);
3857
Abhishek Singh525045c2014-12-15 17:18:45 +05303858 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303859 "htLdpcCapable: %d vhtLdpcCapable: %d"),
3860 pAddBssParams->staContext.fShortGI40Mhz,
3861 pAddBssParams->staContext.maxAmpduSize,
3862 pAddBssParams->staContext.htLdpcCapable,
3863 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 }
3865
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303866 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3867 if ((psessionEntry->limWmeEnabled && (pAssocRsp->wmeEdcaPresent || pAddBssParams->htCapable)) ||
3868 (psessionEntry->limQosEnabled && (pAssocRsp->edcaPresent || pAddBssParams->htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 pAddBssParams->staContext.wmmEnabled = 1;
3870 else
3871 pAddBssParams->staContext.wmmEnabled = 0;
3872
3873 //Update the rates
3874
3875 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3876 if (pStaDs != NULL)
3877 {
3878 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303879 vos_mem_copy((tANI_U8*)&pAddBssParams->staContext.supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 (tANI_U8*)&pStaDs->supportedRates,
3881 sizeof(tSirSupportedRates));
3882 }
3883 else
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003884 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003885
3886 }
3887
3888 //Disable BA. It will be set as part of ADDBA negotiation.
3889 for( i = 0; i < STACFG_MAX_TC; i++ )
3890 {
3891 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3892 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3893 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3894 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3895 }
3896
3897 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
3898
3899#if defined WLAN_FEATURE_VOWIFI
3900 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05303901 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303902 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07003903#endif
3904 // FIXME_GEN4 - Any other value that can be used for initialization?
3905 pAddBssParams->status = eHAL_STATUS_SUCCESS;
3906 pAddBssParams->respReqd = true;
3907
3908 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
3909
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3911 {
3912 pAddBssParams->staContext.p2pCapableSta = 1;
3913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003914
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07003915 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003916
3917#if defined WLAN_FEATURE_VOWIFI_11R
3918 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05303919 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303920 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921#endif
3922
Chet Lanctot186b5732013-03-18 10:26:30 -07003923#ifdef WLAN_FEATURE_11W
3924 if (psessionEntry->limRmfEnabled)
3925 {
3926 pAddBssParams->rmfEnabled = 1;
3927 pAddBssParams->staContext.rmfEnabled = 1;
3928 }
3929#endif
3930
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 // Set a new state for MLME
3932 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
3933 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
3934 else
3935 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003936 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003937
Abhishek Singh525045c2014-12-15 17:18:45 +05303938 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303939 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
3940 pAddBssParams->staContext.encryptType,
3941 pAddBssParams->staContext.p2pCapableSta);
3942
Abhishek Singh525045c2014-12-15 17:18:45 +05303943 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05303944 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
3945 pAddBssParams->halPersona, psessionEntry->limMlmState);
3946
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 //we need to defer the message until we get the response back from HAL.
3948 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3949
3950 msgQ.type = WDA_ADD_BSS_REQ;
3951 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
3952 msgQ.reserved = 0;
3953 msgQ.bodyptr = pAddBssParams;
3954 msgQ.bodyval = 0;
3955
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05303956 limLog( pMac, LOG1, FL("SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
3957 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07003958 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003959
3960 retCode = wdaPostCtrlMsg( pMac, &msgQ );
3961 if( eSIR_SUCCESS != retCode)
3962 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003963 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303964 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003965 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 retCode );
3967 goto returnFailure;
3968
3969 }
3970 else
3971 return retCode;
3972
3973 returnFailure:
3974 // Clean-up will be done by the caller...
3975 return retCode;
3976}
3977
3978
3979
3980
3981tSirRetStatus limStaSendAddBssPreAssoc( tpAniSirGlobal pMac, tANI_U8 updateEntry, tpPESession psessionEntry)
3982{
3983 tSirMsgQ msgQ;
3984 tpAddBssParams pAddBssParams = NULL;
3985 tANI_U32 retCode;
3986 tANI_U8 i;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003987 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003989 tANI_U32 shortGi20MhzSupport;
3990 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 tpSirBssDescription bssDescription = &psessionEntry->pLimJoinReq->bssDescription;
3992
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303993 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
3994 if (NULL == pBeaconStruct)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003995 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303996 limLog(pMac, LOGE, FL("Unable to allocate memory during ADD_BSS") );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003997 return eSIR_MEM_ALLOC_FAILED;
3998 }
3999
Jeff Johnson295189b2012-06-20 16:38:30 -07004000
4001 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304002 pAddBssParams = vos_mem_malloc(sizeof(tAddBssParams));
4003 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 {
4005 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304006 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 retCode = eSIR_MEM_ALLOC_FAILED;
4008 goto returnFailure;
4009 }
4010
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304011 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004012
4013
4014 limExtractApCapabilities( pMac,
4015 (tANI_U8 *) bssDescription->ieFields,
4016 limGetIElenFromBssDescription( bssDescription ),
Jeff Johnson32d95a32012-09-10 13:15:23 -07004017 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07004018
4019 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson32d95a32012-09-10 13:15:23 -07004020 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304021 vos_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
4022 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004023
4024 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304025 vos_mem_copy(pAddBssParams->selfMacAddr,
4026 psessionEntry->selfMacAddr,
4027 sizeof(tSirMacAddr));
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304028 limLog(pMac, LOG1, FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
4029 psessionEntry->smeSessionId,updateEntry,psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004030
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304031 limLog(pMac, LOG1, FL("BSSID: "MAC_ADDRESS_STR),
4032 MAC_ADDR_ARRAY(pAddBssParams->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304034 * top of an already established Infra link. This lead to issues in
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 * concurrent data transfer.
4036 */
4037
4038 pAddBssParams->bssType = psessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
4039 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
4040
4041 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
4042
Jeff Johnson32d95a32012-09-10 13:15:23 -07004043 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 pAddBssParams->updateBss = updateEntry;
4045
4046
Jeff Johnson32d95a32012-09-10 13:15:23 -07004047 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
4048 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
4049 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
4050 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -07004051
4052
Jeff Johnson32d95a32012-09-10 13:15:23 -07004053 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304054 vos_mem_copy(pAddBssParams->rateSet.rate,
4055 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07004056
4057 pAddBssParams->nwType = bssDescription->nwType;
4058
Jeff Johnson32d95a32012-09-10 13:15:23 -07004059 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
4061 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
4062 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304063 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
Jeff Johnson295189b2012-06-20 16:38:30 -07004064
Abhishek Singh525045c2014-12-15 17:18:45 +05304065 limLog(pMac, LOG1, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304066 "cfpCount: %d"),pAddBssParams->bssType, pAddBssParams->beaconInterval,
4067 pAddBssParams->dtimPeriod, pAddBssParams->cfParamSet.cfpCount);
4068
Abhishek Singh525045c2014-12-15 17:18:45 +05304069 limLog(pMac, LOG1, FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304070 " %d numRates: %d "),pAddBssParams->cfParamSet.cfpPeriod,
4071 pAddBssParams->cfParamSet.cfpMaxDuration,
4072 pAddBssParams->cfParamSet.cfpDurRemaining,
4073 pAddBssParams->rateSet.numRates);
4074
Abhishek Singh525045c2014-12-15 17:18:45 +05304075 limLog(pMac, LOG1, FL("nwType:%d shortSlotTimeSupported: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304076 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
4077 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
4078 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
4079 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 // Use the advertised capabilities from the received beacon/PR
Jeff Johnson32d95a32012-09-10 13:15:23 -07004081 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004083 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Abhishek Singh525045c2014-12-15 17:18:45 +05304084 limLog(pMac, LOG1, FL("htCapable: %d"),pAddBssParams->htCapable);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004085 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004087 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
4088 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07004089
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004091 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 (chanWidthSupp) )
4093 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004094 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
4095 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 }
4097 else
4098 {
4099 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004100 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004102 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
4103 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
4104 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304105
Abhishek Singh525045c2014-12-15 17:18:45 +05304106 limLog(pMac, LOG1, FL("htOperMode: %d dualCTSProtection: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304107 "txChannelWidthSet: %d currentExtChannel: %d "),
4108 pAddBssParams->htOperMode, pAddBssParams->dualCTSProtection,
4109 pAddBssParams->txChannelWidthSet,pAddBssParams->currentExtChannel);
4110
Abhishek Singh525045c2014-12-15 17:18:45 +05304111 limLog(pMac, LOG1, FL("llnNonGFCoexist: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304112 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
4113 pAddBssParams->llnNonGFCoexist,
4114 pAddBssParams->fLsigTXOPProtectionFullSupport,
4115 pAddBssParams->fRIFSMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 }
4117 }
4118
4119 pAddBssParams->currentOperChannel = bssDescription->channelId;
Abhishek Singh525045c2014-12-15 17:18:45 +05304120 limLog(pMac, LOG1, FL("currentOperChannel %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304121 pAddBssParams->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004122#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304123 if (psessionEntry->vhtCapability &&
4124 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Jeff Johnsone7245742012-09-05 17:12:55 -07004125 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004126 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
4127 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07004128 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
4129 pAddBssParams->currentOperChannel,
4130 pAddBssParams->currentExtChannel,
4131 psessionEntry->apCenterChan,
4132 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004133 }
4134 else
4135 {
4136 pAddBssParams->vhtCapable = 0;
4137 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304138 limLog(pMac, LOG1, FL("vhtCapable %d vhtTxChannelWidthSet %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304139 "currentExtChannel %d"),pAddBssParams->vhtCapable,
4140 pAddBssParams->vhtTxChannelWidthSet,
4141 pAddBssParams->currentExtChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07004142#endif
4143
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 // Populate the STA-related parameters here
4145 // Note that the STA here refers to the AP
4146 {
4147 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
4148
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304149 vos_mem_copy(pAddBssParams->staContext.bssId,
4150 bssDescription->bssId,
4151 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004152 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
4153
4154 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
4155 pAddBssParams->staContext.uAPSD = 0;
4156 pAddBssParams->staContext.maxSPLen = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004157 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 pAddBssParams->staContext.updateSta = updateEntry;
4159
Abhishek Singh525045c2014-12-15 17:18:45 +05304160 limLog(pMac, LOG1, FL("StaContext: "MAC_ADDRESS_STR
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304161 " shortPreambleSupported: %d"),
4162 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
4163 pAddBssParams->staContext.shortPreambleSupported);
4164
Jeff Johnson32d95a32012-09-10 13:15:23 -07004165 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 {
4167 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
4168 pAddBssParams->staContext.htCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004169 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
4170 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
Abhishek Singh525045c2014-12-15 17:18:45 +05304171 limLog(pMac, LOG1, FL("StaContext htCapable: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304172 "greenFieldCapable: %d lsigTxopProtection: %d"),
4173 pAddBssParams->staContext.htCapable,
4174 pAddBssParams->staContext.greenFieldCapable,
4175 pAddBssParams->staContext.lsigTxopProtection);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004176#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +05304177 if (psessionEntry->vhtCapability &&
4178 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004179 {
4180 pAddBssParams->staContext.vhtCapable = 1;
4181 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
4182 pBeaconStruct->VHTCaps.muBeamformerCap) &&
4183 psessionEntry->txBFIniFeatureEnabled )
4184 {
4185 pAddBssParams->staContext.vhtTxBFCapable = 1;
4186 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05304187 if (pBeaconStruct->VHTCaps.muBeamformerCap &&
4188 psessionEntry->txMuBformee )
4189 {
4190 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
4191 limLog(pMac, LOG1,FL("Enabling MUBformeeCapable for peer"));
4192 /* Dont allow any other MuBf session as concurrency
4193 * is not supported
4194 */
4195 pMac->isMuBfsessionexist = TRUE;
4196 }
4197
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004198 }
4199#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004200 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 (chanWidthSupp) )
4202 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07004203 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004204#ifdef WLAN_FEATURE_11AC
4205 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07004206 {
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004207 pAddBssParams->staContext.vhtTxChannelWidthSet =
4208 pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -07004209 }
Abhishek Singh525045c2014-12-15 17:18:45 +05304210 limLog(pMac, LOG1,FL("StaContext vhtCapable %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304211 "vhtTxChannelWidthSet: %d vhtTxBFCapable: %d"),
4212 pAddBssParams->staContext.vhtCapable,
4213 pAddBssParams->staContext.vhtTxChannelWidthSet,
4214 pAddBssParams->staContext.vhtTxBFCapable);
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07004215#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 }
4217 else
4218 {
4219 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4220 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07004221 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
4222 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
4223 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
4224 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
4225 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07004226 /*
4227 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
4228 * if they are set then we will use what ever Beacon coming from AP
4229 * supports. If these values are set as 0 in ini file then
4230 * we will hardcode this values to 0.
4231 */
4232 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4233 (pMac, WNI_CFG_SHORT_GI_20MHZ,
4234 &shortGi20MhzSupport)))
4235 {
4236 if (VOS_TRUE == shortGi20MhzSupport)
4237 {
4238 pAddBssParams->staContext.fShortGI20Mhz =
4239 (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
4240 }
4241 else
4242 {
4243 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
4244 }
4245 }
4246 else
4247 {
4248 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
4249 "CFG,setting value to default"));)
4250 pAddBssParams->staContext.fShortGI20Mhz =
4251 WNI_CFG_SHORT_GI_20MHZ_STADEF;
4252 }
4253
4254 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
4255 (pMac, WNI_CFG_SHORT_GI_40MHZ,
4256 &shortGi40MhzSupport)))
4257 {
4258 if (VOS_TRUE == shortGi40MhzSupport)
4259 {
4260 pAddBssParams->staContext.fShortGI40Mhz =
4261 (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
4262 }
4263 else
4264 {
4265 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
4266 }
4267 }
4268 else
4269 {
4270 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
4271 "CFG,setting value to default"));)
4272 pAddBssParams->staContext.fShortGI40Mhz =
4273 WNI_CFG_SHORT_GI_40MHZ_STADEF;
4274 }
4275
Jeff Johnson32d95a32012-09-10 13:15:23 -07004276 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Sushant Kaushik4fb4da72015-02-20 21:37:29 +05304277 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08004278 {
4279 pAddBssParams->staContext.htLdpcCapable = 0;
4280 pAddBssParams->staContext.vhtLdpcCapable = 0;
4281 }
4282 else
4283 {
4284 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pBeaconStruct->HTCaps.advCodingCap;
4285 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pBeaconStruct->VHTCaps.ldpcCodingCap;
4286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004287
Jeff Johnson32d95a32012-09-10 13:15:23 -07004288 if( pBeaconStruct->HTInfo.present )
4289 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Abhishek Singh525045c2014-12-15 17:18:45 +05304290 limLog(pMac, LOG1, FL("StaContext txChannelWidthSet: %d mimoPS: %d"
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304291 " delBASupport: %d maxAmsduSize: %d"),
4292 pAddBssParams->staContext.txChannelWidthSet,
4293 pAddBssParams->staContext.mimoPS,
4294 pAddBssParams->staContext.delBASupport,
4295 pAddBssParams->staContext.maxAmsduSize);
4296
Abhishek Singh525045c2014-12-15 17:18:45 +05304297 limLog(pMac, LOG1, FL("maxAmpduDensity: %d fDsssCckMode40Mhz: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304298 "fShortGI20Mhz: %d "),pAddBssParams->staContext.maxAmpduDensity,
4299 pAddBssParams->staContext.fDsssCckMode40Mhz,
4300 pAddBssParams->staContext.fShortGI20Mhz);
4301
Abhishek Singh525045c2014-12-15 17:18:45 +05304302 limLog(pMac, LOG1, FL("fShortGI40Mh: %d maxAmpduSize: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304303 "htLdpcCapable: %d vhtLdpcCapable: %d"),
4304 pAddBssParams->staContext.fShortGI40Mhz,
4305 pAddBssParams->staContext.maxAmpduSize,
4306 pAddBssParams->staContext.htLdpcCapable,
4307 pAddBssParams->staContext.vhtLdpcCapable);
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 }
4309
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05304310 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
4311 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent || pAddBssParams->staContext.htCapable)) ||
4312 (psessionEntry->limQosEnabled && (pBeaconStruct->edcaPresent || pAddBssParams->staContext.htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 pAddBssParams->staContext.wmmEnabled = 1;
4314 else
4315 pAddBssParams->staContext.wmmEnabled = 0;
4316
4317 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -07004318#ifdef WLAN_FEATURE_11AC
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004319 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004320 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry,
4321 &pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -07004322#else
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07004323 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004324 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07004325#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,psessionEntry);
4327
4328 }
4329
4330
4331 //Disable BA. It will be set as part of ADDBA negotiation.
4332 for( i = 0; i < STACFG_MAX_TC; i++ )
4333 {
4334 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
4335 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
4336 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
4337 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
4338 }
4339
4340 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4341
4342#if defined WLAN_FEATURE_VOWIFI
4343 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Abhishek Singh525045c2014-12-15 17:18:45 +05304344 limLog(pMac, LOG1,FL("maxTxPower: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304345 pAddBssParams->maxTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07004346#endif
4347
4348 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4349 pAddBssParams->respReqd = true;
4350
4351 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4352 pAddBssParams->sessionId = psessionEntry->peSessionId;
4353
4354 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4355
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004356 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357
4358#if defined WLAN_FEATURE_VOWIFI_11R
4359 pAddBssParams->extSetStaKeyParamValid = 0;
Abhishek Singh525045c2014-12-15 17:18:45 +05304360 limLog(pMac, LOG1,FL("extSetStaKeyParamValid: %d"),
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304361 pAddBssParams->extSetStaKeyParamValid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004362#endif
4363
Chet Lanctot186b5732013-03-18 10:26:30 -07004364#ifdef WLAN_FEATURE_11W
4365 if (psessionEntry->limRmfEnabled)
4366 {
4367 pAddBssParams->rmfEnabled = 1;
4368 pAddBssParams->staContext.rmfEnabled = 1;
4369 }
4370#endif
4371
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 // Set a new state for MLME
4373
4374 //pMac->lim.gLimMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4375 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4376
Jeff Johnsone7245742012-09-05 17:12:55 -07004377 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004378
Abhishek Singh525045c2014-12-15 17:18:45 +05304379 limLog(pMac, LOG1, FL("staContext wmmEnabled: %d encryptType: %d "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304380 "p2pCapableSta: %d"),pAddBssParams->staContext.wmmEnabled,
4381 pAddBssParams->staContext.encryptType,
4382 pAddBssParams->staContext.p2pCapableSta);
4383
Abhishek Singh525045c2014-12-15 17:18:45 +05304384 limLog(pMac, LOG1, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
Abhishek Singhdcbd8272014-01-09 14:16:01 +05304385 "LimMlm state to %d"), pAddBssParams->bSpectrumMgtEnabled,
4386 pAddBssParams->halPersona, psessionEntry->limMlmState);
4387
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 //we need to defer the message until we get the response back from HAL.
4389 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4390
4391 msgQ.type = WDA_ADD_BSS_REQ;
4392 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4393 msgQ.reserved = 0;
4394 msgQ.bodyptr = pAddBssParams;
4395 msgQ.bodyval = 0;
4396
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05304397 limLog( pMac, LOG1, FL( "SessionId:%d Sending SIR_HAL_ADD_BSS_REQ" ),
4398 psessionEntry->peSessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07004399 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004400
4401 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4402 if( eSIR_SUCCESS != retCode)
4403 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004404 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304405 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004406 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004407 retCode );
4408 goto returnFailure;
4409
4410 }
4411 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07004412 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304413 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 return retCode;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004415 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004416
4417 returnFailure:
4418 // Clean-up will be done by the caller...
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304419 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 return retCode;
4421}
4422
4423
4424
4425
4426
Jeff Johnson295189b2012-06-20 16:38:30 -07004427
4428/** -------------------------------------------------------------
4429\fn limPrepareAndSendDelStaCnf
4430\brief deletes DPH entry
4431 changes the MLM mode for station.
4432 calls limSendDelStaCnf
4433\param tpAniSirGlobal pMac
4434\param tpDphHashNode pStaDs
4435\return none
4436 -------------------------------------------------------------*/
4437
4438
4439void
4440limPrepareAndSendDelStaCnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tSirResultCodes statusCode,tpPESession psessionEntry)
4441{
4442 tANI_U16 staDsAssocId = 0;
4443 tSirMacAddr staDsAddr;
4444 tLimMlmStaContext mlmStaContext;
4445
4446 if(pStaDs == NULL)
4447 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004448 PELOGW(limLog(pMac, LOGW, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 return;
4450 }
4451 staDsAssocId = pStaDs->assocId;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304452 vos_mem_copy((tANI_U8 *)staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 pStaDs->staAddr,
4454 sizeof(tSirMacAddr));
4455
4456 mlmStaContext = pStaDs->mlmStaContext;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304457 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4458 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 {
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304460 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 }
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304462 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
4463
4464 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4465 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 {
4467 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304468 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
4469 psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 limSendDelStaCnf(pMac, staDsAddr, staDsAssocId, mlmStaContext, statusCode,psessionEntry);
4472}
4473
4474/** -------------------------------------------------------------
4475\fn limGetStaRateMode
4476\brief Gets the Station Rate Mode.
4477\param tANI_U8 dot11Mode
4478\return none
4479 -------------------------------------------------------------*/
4480tStaRateMode limGetStaRateMode(tANI_U8 dot11Mode)
4481{
4482 switch(dot11Mode)
4483 {
4484 case WNI_CFG_DOT11_MODE_11A:
4485 return eSTA_11a;
4486 case WNI_CFG_DOT11_MODE_11B:
4487 return eSTA_11b;
4488 case WNI_CFG_DOT11_MODE_11G:
4489 return eSTA_11bg;
4490 case WNI_CFG_DOT11_MODE_11N:
4491 return eSTA_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07004492#ifdef WLAN_FEATURE_11AC
4493 case WNI_CFG_DOT11_MODE_11AC:
4494 return eSTA_11ac;
4495#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 case WNI_CFG_DOT11_MODE_ALL:
4497 default:
4498 return eSTA_11n;
4499
4500 }
4501}
4502
4503/** -------------------------------------------------------------
4504\fn limInitPreAuthTimerTable
4505\brief Initialize the Pre Auth Tanle and creates the timer for
4506 each node for the timeout value got from cfg.
4507\param tpAniSirGlobal pMac
4508\param tpLimPreAuthTable pPreAuthTimerTable
4509\return none
4510 -------------------------------------------------------------*/
4511void limInitPreAuthTimerTable(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4512{
4513 tANI_U32 cfgValue;
4514 tANI_U32 authNodeIdx;
4515 tpLimPreAuthNode pAuthNode = pPreAuthTimerTable->pTable;
4516
4517 // Get AUTH_RSP Timers value
4518
4519 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4520 &cfgValue) != eSIR_SUCCESS)
4521 {
4522 /*
4523 ** Could not get AUTH_RSP timeout value
4524 ** from CFG. Log error.
4525 **/
4526 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004527 FL("could not retrieve AUTH_RSP timeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 return;
4529 }
4530
4531 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4532 for(authNodeIdx=0; authNodeIdx<pPreAuthTimerTable->numEntry; authNodeIdx++, pAuthNode++)
4533 {
4534 if (tx_timer_create(&pAuthNode->timer,
4535 "AUTH RESPONSE TIMEOUT",
4536 limAuthResponseTimerHandler,
4537 authNodeIdx,
4538 cfgValue,
4539 0,
4540 TX_NO_ACTIVATE) != TX_SUCCESS)
4541 {
4542 // Cannot create timer. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004543 limLog(pMac, LOGP, FL("Cannot create Auth Rsp timer of Index :%d."), authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 return;
4545 }
4546 pAuthNode->authNodeIdx = (tANI_U8)authNodeIdx;
4547 pAuthNode->fFree = 1;
4548 }
4549
4550}
4551
4552/** -------------------------------------------------------------
4553\fn limAcquireFreePreAuthNode
4554\brief Retrives a free Pre Auth node from Pre Auth Table.
4555\param tpAniSirGlobal pMac
4556\param tpLimPreAuthTable pPreAuthTimerTable
4557\return none
4558 -------------------------------------------------------------*/
4559tLimPreAuthNode * limAcquireFreePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4560{
4561 tANI_U32 i;
4562 tLimPreAuthNode *pTempNode = pPreAuthTimerTable->pTable;
4563 for (i=0; i<pPreAuthTimerTable->numEntry; i++,pTempNode++)
4564 {
4565 if (pTempNode->fFree == 1)
4566 {
4567 pTempNode->fFree = 0;
4568 return pTempNode;
4569 }
4570 }
4571
4572 return NULL;
4573}
4574
4575/** -------------------------------------------------------------
4576\fn limGetPreAuthNodeFromIndex
4577\brief Depending on the Index this retrives the pre auth node.
4578\param tpAniSirGlobal pMac
4579\param tpLimPreAuthTable pAuthTable
4580\param tANI_U32 authNodeIdx
4581\return none
4582 -------------------------------------------------------------*/
4583tLimPreAuthNode * limGetPreAuthNodeFromIndex(tpAniSirGlobal pMac,
4584 tpLimPreAuthTable pAuthTable, tANI_U32 authNodeIdx)
4585{
4586 if ((authNodeIdx >= pAuthTable->numEntry) || (pAuthTable->pTable == NULL))
4587 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004588 limLog(pMac, LOGE, FL("Invalid Auth Timer Index : %d NumEntry : %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 authNodeIdx, pAuthTable->numEntry);
4590 return NULL;
4591 }
4592
4593 return pAuthTable->pTable + authNodeIdx;
4594}
4595
4596/* Util API to check if the channels supported by STA is within range */
4597tSirRetStatus limIsDot11hSupportedChannelsValid(tpAniSirGlobal pMac, tSirAssocReq *assoc)
4598{
4599 /*
4600 * Allow all the stations to join with us.
4601 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4602 * as an input into an algorithm used to select a new channel for the BSS.
4603 * The specification of the algorithm is beyond the scope of this amendment.
4604 */
4605
4606 return (eSIR_SUCCESS);
4607}
4608
4609/* Util API to check if the txpower supported by STA is within range */
4610tSirRetStatus limIsDot11hPowerCapabilitiesInRange(tpAniSirGlobal pMac, tSirAssocReq *assoc,tpPESession psessionEntry)
4611{
4612 tPowerdBm localMaxTxPower;
4613 tANI_U32 localPwrConstraint;
4614
4615 localMaxTxPower = cfgGetRegulatoryMaxTransmitPower(pMac, psessionEntry->currentOperChannel);
4616
4617 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004618 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 return eSIR_FAILURE;
4620 }
4621 localMaxTxPower -= (tPowerdBm)localPwrConstraint;
4622
4623 /**
4624 * The min Tx Power of the associating station should not be greater than (regulatory
4625 * max tx power - local power constraint configured on AP).
4626 */
4627 if(assoc->powerCapability.minTxPower > localMaxTxPower)
4628 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004629 limLog(pMac, LOGW, FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 assoc->powerCapability.minTxPower, localMaxTxPower);
4631 return (eSIR_FAILURE);
4632 }
4633
4634 return (eSIR_SUCCESS);
4635}
4636
4637/** -------------------------------------------------------------
4638\fn limFillRxHighestSupportedRate
4639\brief Fills in the Rx Highest Supported Data Rate field from
4640\ the 'supported MCS set' field in HT capability element.
4641\param tpAniSirGlobal pMac
4642\param tpSirSupportedRates pRates
4643\param tANI_U8* pSupportedMCSSet
4644\return none
4645 -------------------------------------------------------------*/
4646void limFillRxHighestSupportedRate(tpAniSirGlobal pMac, tANI_U16 *rxHighestRate, tANI_U8* pSupportedMCSSet)
4647{
4648 tSirMacRxHighestSupportRate *pRxHighestRate;
4649 tANI_U8 *pBuf;
4650 tANI_U16 rate=0;
4651
4652 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4653 rate = limGetU16(pBuf);
4654
4655 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4656 *rxHighestRate = pRxHighestRate->rate;
4657
4658 return;
4659}
Chet Lanctot186b5732013-03-18 10:26:30 -07004660
4661#ifdef WLAN_FEATURE_11W
4662/** -------------------------------------------------------------
4663\fn limSendSmeUnprotectedMgmtFrameInd
4664\brief Forwards the unprotected management frame to SME.
4665\param tpAniSirGlobal pMac
4666\param frameType - 802.11 frame type
4667\param frame - frame buffer
4668\param sessionId - id for the current session
4669\param psessionEntry - PE session context
4670\return none
4671 -------------------------------------------------------------*/
4672void limSendSmeUnprotectedMgmtFrameInd(
4673 tpAniSirGlobal pMac, tANI_U8 frameType,
4674 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
4675 tpPESession psessionEntry)
4676{
4677 tSirMsgQ mmhMsg;
4678 tSirSmeUnprotMgmtFrameInd * pSirSmeMgmtFrame = NULL;
4679 tANI_U16 length;
4680
4681 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4682
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304683 pSirSmeMgmtFrame = vos_mem_malloc(length);
4684 if (NULL == pSirSmeMgmtFrame)
Chet Lanctot186b5732013-03-18 10:26:30 -07004685 {
4686 limLog(pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304687 FL("AllocateMemory failed for tSirSmeUnprotectedMgmtFrameInd"));
Chet Lanctot186b5732013-03-18 10:26:30 -07004688 return;
4689 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304690 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Chet Lanctot186b5732013-03-18 10:26:30 -07004691
4692 pSirSmeMgmtFrame->sessionId = sessionId;
4693 pSirSmeMgmtFrame->frameType = frameType;
4694
4695 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
4696 pSirSmeMgmtFrame->frameLen = frameLen;
4697
4698 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4699 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4700 mmhMsg.bodyval = 0;
4701
4702 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4703 return;
4704}
4705#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004706
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004707#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004708/** -------------------------------------------------------------
4709\fn limSendSmeTsmIEInd
4710\brief Forwards the TSM IE information to SME.
4711\param tpAniSirGlobal pMac
4712\param psessionEntry - PE session context
4713\param tid - traffic id
4714\param state - tsm state (enabled/disabled)
4715\param measurementInterval - measurement interval
4716\return none
4717 -------------------------------------------------------------*/
4718void limSendSmeTsmIEInd(tpAniSirGlobal pMac, tpPESession psessionEntry,
4719 tANI_U8 tid, tANI_U8 state, tANI_U16 measInterval)
4720{
4721 tSirMsgQ mmhMsg;
4722 tpSirSmeTsmIEInd pSirSmeTsmIeInd = NULL;
4723
4724 if (!pMac || !psessionEntry)
4725 {
4726 return;
4727 }
4728 pSirSmeTsmIeInd = vos_mem_malloc(sizeof(tSirSmeTsmIEInd));
4729 if (NULL == pSirSmeTsmIeInd)
4730 {
4731 limLog(pMac, LOGP,
4732 FL("AllocateMemory failed for tSirSmeTsmIEInd"));
4733 return;
4734 }
4735 vos_mem_set((void*)pSirSmeTsmIeInd, sizeof(tSirSmeTsmIEInd), 0);
4736
4737 pSirSmeTsmIeInd->sessionId = psessionEntry->smeSessionId;
4738 pSirSmeTsmIeInd->tsmIe.tsid = tid;
4739 pSirSmeTsmIeInd->tsmIe.state= state;
4740 pSirSmeTsmIeInd->tsmIe.msmt_interval= measInterval;
4741
4742 mmhMsg.type = eWNI_SME_TSM_IE_IND;
4743 mmhMsg.bodyptr = pSirSmeTsmIeInd;
4744 mmhMsg.bodyval = 0;
4745
4746 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4747 return;
4748}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004749#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004750
4751