blob: caf77f5b5e9b5822df7483512daa5f7e59192bad [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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.
20 */
21
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
28/*
29 * This file lim_assoc_utils.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 "cds_api.h"
41#include "ani_global.h"
42#include "wni_api.h"
43#include "sir_common.h"
44
45#include "wni_cfg.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_assoc_utils.h"
52#include "lim_security_utils.h"
53#include "lim_ser_des_utils.h"
54#include "lim_sta_hash_api.h"
55#include "lim_admit_control.h"
56#include "lim_send_messages.h"
57#include "lim_ibss_peer_mgmt.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059#include "lim_session.h"
60
Anurag Chouhan6d760662016-02-20 16:05:43 +053061#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062#include "wma_types.h"
63#include "lim_types.h"
64
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065/**
Srinivas Girigowdacba74732016-01-14 17:35:25 -080066 * lim_cmp_ssid() - utility function to compare SSIDs
67 * @rx_ssid: Received SSID
68 * @session_entry: Session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 * This function is called in various places within LIM code
Srinivas Girigowdacba74732016-01-14 17:35:25 -080071 * to determine whether received SSID is same as SSID in use.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072 *
Srinivas Girigowdacba74732016-01-14 17:35:25 -080073 * Return: true if SSID matched, false otherwise.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053075uint32_t lim_cmp_ssid(tSirMacSSid *rx_ssid, tpPESession session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053077 return qdf_mem_cmp(rx_ssid, &session_entry->ssId,
Srinivas Girigowdacba74732016-01-14 17:35:25 -080078 session_entry->ssId.length);
79}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080
81/**
82 * lim_compare_capabilities()
83 *
84 ***FUNCTION:
85 * This function is called during Association/Reassociation
86 * frame handling to determine whether received capabilities
87 * match with local capabilities or not.
88 *
89 ***LOGIC:
90 *
91 ***ASSUMPTIONS:
92 * NA
93 *
94 ***NOTE:
95 * NA
96 *
97 * @param pMac - Pointer to Global MAC structure
98 * @param pAssocReq - Pointer to received Assoc Req frame
99 * @param pLocalCapabs - Pointer to local capabilities
100 *
101 * @return status - true for Capabilitity match else false.
102 */
103
104uint8_t
105lim_compare_capabilities(tpAniSirGlobal pMac,
106 tSirAssocReq *pAssocReq,
107 tSirMacCapabilityInfo *pLocalCapabs,
108 tpPESession psessionEntry)
109{
110 uint32_t val;
111
112 if ((LIM_IS_AP_ROLE(psessionEntry) ||
113 LIM_IS_BT_AMP_AP_ROLE(psessionEntry)) &&
114 (pAssocReq->capabilityInfo.ibss)) {
115 /* Requesting STA asserting IBSS capability. */
116 lim_log(pMac, LOG1,
117 FL("Requesting STA asserting IBSS capability"));
118 return false;
119 }
120 /* Compare CF capabilities */
121 if (pAssocReq->capabilityInfo.cfPollable ||
122 pAssocReq->capabilityInfo.cfPollReq) {
123 /* AP does not support PCF functionality */
124 lim_log(pMac, LOG1,
125 FL(" AP does not support PCF functionality"));
126 return false;
127 }
128 /* Compare short preamble capability */
129 if (pAssocReq->capabilityInfo.shortPreamble &&
130 (pAssocReq->capabilityInfo.shortPreamble !=
131 pLocalCapabs->shortPreamble)) {
132 /* Allowing a STA requesting short preamble while */
133 /* AP does not support it */
134 }
135
136 lim_log(pMac, LOG1, "QoS in AssocReq: %d, local capabs qos: %d",
137 pAssocReq->capabilityInfo.qos, pLocalCapabs->qos);
138
139 /* Compare QoS capability */
140 if (pAssocReq->capabilityInfo.qos &&
141 (pAssocReq->capabilityInfo.qos != pLocalCapabs->qos)) {
142 /*Temporary hack for UPF to skip 11e capability check in order to interop with
143 CSR - proper fix needs to be put in place */
144 lim_log(pMac, LOG1,
145 FL
146 ("Received unmatched QOS but cfg to suppress - continuing"));
147 }
148
149 /*
150 * If AP supports shortSlot and if apple user has
151 * enforced association only from shortSlot station,
152 * then AP must reject any station that does not support
153 * shortSlot
154 */
155 if ((LIM_IS_AP_ROLE(psessionEntry) ||
156 LIM_IS_BT_AMP_AP_ROLE(psessionEntry)) &&
157 (pLocalCapabs->shortSlotTime == 1)) {
158 if (wlan_cfg_get_int
159 (pMac, WNI_CFG_ACCEPT_SHORT_SLOT_ASSOC_ONLY,
160 &val) != eSIR_SUCCESS) {
161 lim_log(pMac, LOGP,
162 FL
163 ("error getting WNI_CFG_FORCE_SHORT_SLOT_ASSOC_ONLY "));
164 return false;
165 }
166 if (val) {
167 if (pAssocReq->capabilityInfo.shortSlotTime !=
168 pLocalCapabs->shortSlotTime) {
169 lim_log(pMac, LOGE,
170 FL
171 ("AP rejects association as station doesnt support shortslot time"));
172 return false;
173 }
174 return false;
175 }
176 }
177
178 return true;
179} /****** end lim_compare_capabilities() ******/
180
181/**
182 * lim_check_rx_basic_rates()
183 *
184 ***FUNCTION:
185 * This function is called during Association/Reassociation
186 * frame handling to determine whether received rates in
187 * Assoc/Reassoc request frames include all BSS basic rates
188 * or not.
189 *
190 ***LOGIC:
191 *
192 ***ASSUMPTIONS:
193 * NA
194 *
195 ***NOTE:
196 * NA
197 *
198 * @param rxRateSet - pointer to SSID structure
199 *
200 * @return status - true if ALL BSS basic rates are present in the
201 * received rateset else false.
202 */
203
204uint8_t
205lim_check_rx_basic_rates(tpAniSirGlobal pMac, tSirMacRateSet rxRateSet,
206 tpPESession psessionEntry)
207{
208 tSirMacRateSet *pRateSet, basicRate;
209 uint8_t i, j, k, match;
210
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530211 pRateSet = qdf_mem_malloc(sizeof(tSirMacRateSet));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 if (NULL == pRateSet) {
213 lim_log(pMac, LOGP,
214 FL("call to AllocateMemory failed for RATESET"));
215
216 return false;
217 }
218
219 /* Copy operational rate set from session Entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530220 qdf_mem_copy(pRateSet->rate, (psessionEntry->rateSet.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 psessionEntry->rateSet.numRates);
222
223 pRateSet->numRates = psessionEntry->rateSet.numRates;
224
225 /* Extract BSS basic rateset from operational rateset */
226 for (i = 0, j = 0;
227 ((i < pRateSet->numRates) && (i < SIR_MAC_RATESET_EID_MAX)); i++) {
228 if ((pRateSet->rate[i] & 0x80) == 0x80) {
229 /* msb is set, so this is a basic rate */
230 basicRate.rate[j++] = pRateSet->rate[i];
231 }
232 }
233
234 /*
235 * For each BSS basic rate, find if it is present in the
236 * received rateset.
237 */
238 for (k = 0; k < j; k++) {
239 match = 0;
240 for (i = 0;
241 ((i < rxRateSet.numRates)
242 && (i < SIR_MAC_RATESET_EID_MAX)); i++) {
243 if ((rxRateSet.rate[i] | 0x80) == basicRate.rate[k])
244 match = 1;
245 }
246
247 if (!match) {
248 /* Free up memory allocated for rateset */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530249 qdf_mem_free((uint8_t *) pRateSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250
251 return false;
252 }
253 }
254
255 /* Free up memory allocated for rateset */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530256 qdf_mem_free((uint8_t *) pRateSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257
258 return true;
259} /****** end lim_check_rx_basic_rates() ******/
260
261/**
262 * lim_check_mcs_set()
263 *
264 ***FUNCTION:
265 * This function is called during Association/Reassociation
266 * frame handling to determine whether received MCS rates in
267 * Assoc/Reassoc request frames includes all Basic MCS Rate Set or not.
268 *
269 ***LOGIC:
270 *
271 ***ASSUMPTIONS:
272 * NA
273 *
274 ***NOTE:
275 * NA
276 *
277 * @param supportedMCSSet - pointer to Supported MCS Rate Set
278 *
279 * @return status - true if ALL MCS Basic Rate Set rates are present in the
280 * received rateset else false.
281 */
282
283uint8_t lim_check_mcs_set(tpAniSirGlobal pMac, uint8_t *supportedMCSSet)
284{
285 uint8_t basicMCSSet[SIZE_OF_BASIC_MCS_SET] = { 0 };
286 uint32_t cfgLen = 0;
287 uint8_t i;
288 uint8_t validBytes;
289 uint8_t lastByteMCSMask = 0x1f;
290
291 cfgLen = WNI_CFG_BASIC_MCS_SET_LEN;
292 if (wlan_cfg_get_str(pMac, WNI_CFG_BASIC_MCS_SET,
293 (uint8_t *) basicMCSSet,
294 (uint32_t *) &cfgLen) != eSIR_SUCCESS) {
295 /* / Could not get Basic MCS rateset from CFG. Log error. */
296 lim_log(pMac, LOGP, FL("could not retrieve Basic MCS rateset"));
297 return false;
298 }
299
300 validBytes = VALID_MCS_SIZE / 8;
301
302 /* check if all the Basic MCS Bits are set in supported MCS bitmap */
303 for (i = 0; i < validBytes; i++) {
304 if ((basicMCSSet[i] & supportedMCSSet[i]) != basicMCSSet[i]) {
305 /* Log is avaiable in calling function in file lim_process_assoc_req_frame.c */
306 lim_log(pMac, LOGW,
307 FL
308 ("One of Basic MCS Set Rates is not supported by the Station."));
309 return false;
310 }
311 }
312
313 /* check the last 5 bits of the valid MCS bitmap */
314 if (((basicMCSSet[i] & lastByteMCSMask) &
315 (supportedMCSSet[i] & lastByteMCSMask)) !=
316 (basicMCSSet[i] & lastByteMCSMask)) {
317 lim_log(pMac, LOGW,
318 FL
319 ("One of Basic MCS Set Rates is not supported by the Station."));
320 return false;
321 }
322
323 return true;
324}
325
326#define SECURITY_SUITE_TYPE_MASK 0xFF
327#define SECURITY_SUITE_TYPE_WEP40 0x1
328#define SECURITY_SUITE_TYPE_TKIP 0x2
329#define SECURITY_SUITE_TYPE_CCMP 0x4
330#define SECURITY_SUITE_TYPE_WEP104 0x4
331
332/**
333 * lim_check_rx_rsn_ie_match()- validate received rsn ie with supported cipher
334 * suites.
335 * @mac_ctx: pointer to global mac structure
336 * @rx_rsn_ie: received rsn IE
337 * @session_entry: pe session entry
338 * @sta_is_ht: peer station HT capability
339 * @pmf_connection: set to true if this is pmf connection
340 *
341 * This function is called during Association/Reassociation
342 * frame handling to determine whether received RSN in
343 * Assoc/Reassoc request frames include supported cipher suites or not.
344 *
345 * Return: eSIR_SUCCESS if ALL BSS basic rates are present in the
346 * received rateset else failure status.
347 */
348
349uint8_t
350lim_check_rx_rsn_ie_match(tpAniSirGlobal mac_ctx, tDot11fIERSN rx_rsn_ie,
351 tpPESession session_entry, uint8_t sta_is_ht,
352 bool *pmf_connection)
353{
354 tDot11fIERSN *rsn_ie;
355 uint8_t i, j, match, only_non_ht_cipher = 1;
356#ifdef WLAN_FEATURE_11W
357 bool we_are_pmf_capable;
358 bool we_require_pmf;
359 bool they_are_pmf_capable;
360 bool they_require_pmf;
361#endif
362
363 /* RSN IE should be received from PE */
364 rsn_ie = &session_entry->gStartBssRSNIe;
365
366 /* Check groupwise cipher suite */
367 for (i = 0; i < sizeof(rx_rsn_ie.gp_cipher_suite); i++)
368 if (rsn_ie->gp_cipher_suite[i] !=
369 rx_rsn_ie.gp_cipher_suite[i]) {
370 lim_log(mac_ctx, LOG3,
371 FL("Invalid groupwise cipher suite"));
372 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
373 }
374
375 /*
376 * For each Pairwise cipher suite check whether we support
377 * received pairwise
378 */
379 match = 0;
380 for (i = 0; i < rx_rsn_ie.pwise_cipher_suite_count; i++) {
381 for (j = 0; j < rsn_ie->pwise_cipher_suite_count; j++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530382 if (!qdf_mem_cmp(&rx_rsn_ie.pwise_cipher_suites[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 &rsn_ie->pwise_cipher_suites[j],
384 sizeof(rsn_ie->pwise_cipher_suites[j]))) {
385 match = 1;
386 break;
387 }
388 }
389
390 if ((sta_is_ht)
391#ifdef ANI_LITTLE_BYTE_ENDIAN
392 &&
393 ((rx_rsn_ie.pwise_cipher_suites[i][3] &
394 SECURITY_SUITE_TYPE_MASK) ==
395 SECURITY_SUITE_TYPE_CCMP))
396#else
397 &&
398 ((rx_rsn_ie.pwise_cipher_suites[i][0] &
399 SECURITY_SUITE_TYPE_MASK) ==
400 SECURITY_SUITE_TYPE_CCMP))
401#endif
402 only_non_ht_cipher = 0;
403
404 }
405
406 if ((!match) || ((sta_is_ht) && only_non_ht_cipher)) {
407 lim_log(mac_ctx, LOG1, FL("Invalid pairwise cipher suite"));
408 return eSIR_MAC_INVALID_PAIRWISE_CIPHER_STATUS;
409 }
410 /*
411 * Check RSN capabilities
412 * Bit 0 of First Byte - PreAuthentication Capability
413 */
414 if (((rx_rsn_ie.RSN_Cap[0] >> 0) & 0x1) == true) {
415 /* this is supported by AP only */
416 lim_log(mac_ctx, LOG1,
417 FL("Invalid RSN information element capabilities"));
418 return eSIR_MAC_INVALID_RSN_IE_CAPABILITIES_STATUS;
419 }
420
421 *pmf_connection = false;
422
423#ifdef WLAN_FEATURE_11W
424 we_are_pmf_capable = session_entry->pLimStartBssReq->pmfCapable;
425 we_require_pmf = session_entry->pLimStartBssReq->pmfRequired;
426 they_are_pmf_capable = (rx_rsn_ie.RSN_Cap[0] >> 7) & 0x1;
427 they_require_pmf = (rx_rsn_ie.RSN_Cap[0] >> 6) & 0x1;
428
429 if ((they_require_pmf && they_are_pmf_capable && !we_are_pmf_capable) ||
430 (we_require_pmf && !they_are_pmf_capable)) {
431 lim_log(mac_ctx, LOG1,
432 FL("Association fail, robust management frames policy"
433 " violation they_require_pmf =%d"
434 " theyArePMFCapable %d weArePMFCapable %d"
435 " weRequirePMF %d theyArePMFCapable %d"),
436 they_require_pmf, they_are_pmf_capable,
437 we_are_pmf_capable, we_require_pmf,
438 they_are_pmf_capable);
439 return eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION;
440 }
441
442 if (they_are_pmf_capable && we_are_pmf_capable)
443 *pmf_connection = true;
444
445 lim_log(mac_ctx, LOG1,
446 FL("weAreCapable %d, weRequire %d, theyAreCapable %d,"
447 " theyRequire %d, PMFconnection %d"),
448 we_are_pmf_capable, we_require_pmf, they_are_pmf_capable,
449 they_require_pmf, *pmf_connection);
450#endif
451
452 return eSIR_SUCCESS;
453}
454
455/**
456 * lim_check_rx_wpa_ie_match() - to check supported cipher suites
457 *
458 * @mac: pointer to global mac structure
459 * @rx_wpaie: Received WPA IE in (Re)Assco req
460 * @session_entry: pointer to PE session
461 * @sta_is_ht: peer station is HT
462 *
463 * This function is called during Association/Reassociation
464 * frame handling to determine whether received RSN in
465 * Assoc/Reassoc request frames include supported cipher suites or not.
466 *
467 * Return: Success if ALL BSS basic rates are present in the
468 * received rateset else failure status.
469 */
470
471uint8_t
472lim_check_rx_wpa_ie_match(tpAniSirGlobal mac, tDot11fIEWPA rx_wpaie,
473 tpPESession session_entry, uint8_t sta_is_ht)
474{
475 tDot11fIEWPA *wpa_ie;
476 uint8_t i, j, match, only_non_ht_cipher = 1;
477
478 /* WPA IE should be received from PE */
479 wpa_ie = &session_entry->gStartBssWPAIe;
480
481 /* Check groupwise cipher suite */
482 for (i = 0; i < 4; i++) {
483 if (wpa_ie->multicast_cipher[i] != rx_wpaie.multicast_cipher[i]) {
484 lim_log(mac, LOG1,
485 FL("Invalid groupwise cipher suite"));
486 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
487 }
488 }
489
490 /*
491 * For each Pairwise cipher suite check whether we support
492 * received pairwise
493 */
494 match = 0;
495 for (i = 0; i < rx_wpaie.unicast_cipher_count; i++) {
496 for (j = 0; j < wpa_ie->unicast_cipher_count; j++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530497 if (!qdf_mem_cmp(rx_wpaie.unicast_ciphers[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 wpa_ie->unicast_ciphers[j], 4)) {
499 match = 1;
500 break;
501 }
502 }
503
504 if ((sta_is_ht)
505#ifdef ANI_LITTLE_BYTE_ENDIAN
506 &&
507 ((rx_wpaie.
508 unicast_ciphers[i][3] & SECURITY_SUITE_TYPE_MASK) ==
509 SECURITY_SUITE_TYPE_CCMP))
510#else
511 &&
512 ((rx_wpaie.
513 unicast_ciphers[i][0] & SECURITY_SUITE_TYPE_MASK) ==
514 SECURITY_SUITE_TYPE_CCMP))
515#endif
516 {
517 only_non_ht_cipher = 0;
518 }
519
520 }
521
522 if ((!match) || ((sta_is_ht) && only_non_ht_cipher)) {
523 lim_log(mac, LOG1, FL("Invalid pairwise cipher suite"));
524 return eSIR_MAC_CIPHER_SUITE_REJECTED_STATUS;
525 }
526
527 return eSIR_SUCCESS;
528}
529
530/**
531 * lim_cleanup_rx_path()
532 *
533 ***FUNCTION:
534 * This function is called to cleanup STA state at SP & RFP.
535 *
536 ***LOGIC:
537 * To circumvent RFP's handling of dummy packet when it does not
538 * have an incomplete packet for the STA to be deleted, a packet
539 * with 'more framgents' bit set will be queued to RFP's WQ before
540 * queuing 'dummy packet'.
541 * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
542 * (Disassociation frame) and routing flags in BD set to eCPU's
543 * Low Priority WQ.
544 * RFP cleans up its local context for the STA id mentioned in the
545 * BD and then pushes BD to eCPU's low priority WQ.
546 *
547 ***ASSUMPTIONS:
548 * NA
549 *
550 ***NOTE:
551 * NA
552 *
553 * @param pMac Pointer to Global MAC structure
554 * @param pStaDs Pointer to the per STA data structure
555 * initialized by LIM and maintained at DPH
556 *
557 * @return None
558 */
559
560tSirRetStatus
561lim_cleanup_rx_path(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
562 tpPESession psessionEntry)
563{
564 tSirRetStatus retCode = eSIR_SUCCESS;
565
566 lim_log(pMac, LOG1, FL("Cleanup Rx Path for AID : %d"
567 "psessionEntry->limSmeState : %d, mlmState : %d"),
568 pStaDs->assocId, psessionEntry->limSmeState,
569 pStaDs->mlmStaContext.mlmState);
570
571 psessionEntry->isCiscoVendorAP = false;
572
573 if (pMac->lim.gLimAddtsSent) {
574 MTRACE(mac_trace
575 (pMac, TRACE_CODE_TIMER_DEACTIVATE,
576 psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
577 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
578 }
579
580 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE) {
581 lim_deactivate_and_change_per_sta_id_timer(pMac, eLIM_CNF_WAIT_TIMER,
582 pStaDs->assocId);
583
584 if (!pStaDs->mlmStaContext.updateContext) {
585 /**
586 * There is no context at Polaris to delete.
587 * Release our assigned AID back to the free pool
588 */
589 if (LIM_IS_AP_ROLE(psessionEntry) ||
590 LIM_IS_BT_AMP_AP_ROLE(psessionEntry)) {
591 lim_release_peer_idx(pMac, pStaDs->assocId,
592 psessionEntry);
593 }
594 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
595 pStaDs->assocId, psessionEntry);
596
597 return retCode;
598 }
599 }
600 /* delete all tspecs associated with this sta. */
601 lim_admit_control_delete_sta(pMac, pStaDs->assocId);
602
603 /**
604 * Make STA hash entry invalid at eCPU so that DPH
605 * does not process any more data packets and
606 * releases those BDs
607 */
608 pStaDs->valid = 0;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800609 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
610 /* Any roaming related changes should be above this line */
611 if (psessionEntry->bRoamSynchInProgress)
612 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
614
615 if (LIM_IS_STA_ROLE(psessionEntry) ||
616 LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
617 MTRACE(mac_trace
618 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
619 eLIM_MLM_WT_DEL_STA_RSP_STATE));
620 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
621 /* Deactivating probe after heart beat timer */
622 lim_deactivate_and_change_timer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
623 lim_deactivate_and_change_timer(pMac, eLIM_JOIN_FAIL_TIMER);
624 pMac->lim.gLastBeaconDtimCount = 0;
625 pMac->lim.gLastBeaconDtimPeriod = 0;
626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627
628 }
629#ifdef WLAN_DEBUG
630 /* increment a debug count */
631 pMac->lim.gLimNumRxCleanup++;
632#endif
Abhishek Singh96bda8e2015-12-03 16:45:35 +0530633 /* Do DEL BSS or DEL STA only if ADD BSS was success */
634 if (!psessionEntry->add_bss_failed) {
635 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
636 retCode =
637 lim_del_bss(pMac, pStaDs, psessionEntry->bssIdx,
638 psessionEntry);
639 } else
640 retCode = lim_del_sta(pMac,
641 pStaDs, true, psessionEntry);
642 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643
644 return retCode;
645
646} /*** end lim_cleanup_rx_path() ***/
647
648/**
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800649 * lim_send_del_sta_cnf() - Send Del sta confirmation
650 * @pMac: Pointer to Global MAC structure
651 * @sta_dsaddr: sta ds address
652 * @staDsAssocId: sta ds association id
653 * @mlmStaContext: MLM station context
654 * @statusCode: Status code
655 * @psessionEntry: Session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 *
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800657 * This function is called to send appropriate CNF message to SME.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 *
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800659 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661void
Anurag Chouhan6d760662016-02-20 16:05:43 +0530662lim_send_del_sta_cnf(tpAniSirGlobal pMac, struct qdf_mac_addr sta_dsaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 uint16_t staDsAssocId, tLimMlmStaContext mlmStaContext,
664 tSirResultCodes statusCode, tpPESession psessionEntry)
665{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 tLimMlmDisassocCnf mlmDisassocCnf;
667 tLimMlmDeauthCnf mlmDeauthCnf;
668 tLimMlmPurgeStaInd mlmPurgeStaInd;
669
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800670 lim_log(pMac, LOG1,
671 FL("Sessionid: %d staDsAssocId: %d Trigger: %d statusCode: %d sta_dsaddr: "MAC_ADDRESS_STR),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 psessionEntry->peSessionId, staDsAssocId,
673 mlmStaContext.cleanupTrigger, statusCode,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800674 MAC_ADDR_ARRAY(sta_dsaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675
676 if (LIM_IS_STA_ROLE(psessionEntry) ||
677 LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
678 /* Set BSSID at CFG to null */
679 tSirMacAddr nullAddr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
680
681 sir_copy_mac_addr(nullAddr, psessionEntry->bssId);
682
683 /* Free up buffer allocated for JoinReq held by */
684 /* MLM state machine */
685 if (psessionEntry->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530686 qdf_mem_free(psessionEntry->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 psessionEntry->pLimMlmJoinReq = NULL;
688 }
689
690 psessionEntry->limAID = 0;
691
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +0530692 } else if (
693 (mlmStaContext.cleanupTrigger ==
694 eLIM_LINK_MONITORING_DISASSOC) ||
695 (mlmStaContext.cleanupTrigger ==
696 eLIM_LINK_MONITORING_DEAUTH)) {
697 /* only for non-STA cases PE/SME is serialized */
698 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 }
700
701 if ((mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +0530702 eLIM_HOST_DISASSOC) ||
703 (mlmStaContext.cleanupTrigger ==
704 eLIM_LINK_MONITORING_DISASSOC) ||
705 (mlmStaContext.cleanupTrigger ==
706 eLIM_PROMISCUOUS_MODE_DISASSOC)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 /**
708 * Host or LMM driven Disassociation.
709 * Issue Disassoc Confirm to SME.
710 */
711 lim_log(pMac, LOGW,
712 FL("Lim Posting DISASSOC_CNF to Sme. Trigger: %d"),
713 mlmStaContext.cleanupTrigger);
714
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530715 qdf_mem_copy((uint8_t *) &mlmDisassocCnf.peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530716 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 mlmDisassocCnf.resultCode = statusCode;
718 mlmDisassocCnf.disassocTrigger = mlmStaContext.cleanupTrigger;
719 /* Update PE session Id */
720 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
721
722 lim_post_sme_message(pMac,
723 LIM_MLM_DISASSOC_CNF,
724 (uint32_t *) &mlmDisassocCnf);
725 } else if ((mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +0530726 eLIM_HOST_DEAUTH) ||
727 (mlmStaContext.cleanupTrigger ==
728 eLIM_LINK_MONITORING_DEAUTH)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 /**
730 * Host or LMM driven Deauthentication.
731 * Issue Deauth Confirm to SME.
732 */
733 lim_log(pMac, LOGW,
734 FL("Lim Posting DEAUTH_CNF to Sme. Trigger: %d"),
735 mlmStaContext.cleanupTrigger);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530736 qdf_copy_macaddr(&mlmDeauthCnf.peer_macaddr, &sta_dsaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 mlmDeauthCnf.resultCode = statusCode;
738 mlmDeauthCnf.deauthTrigger = mlmStaContext.cleanupTrigger;
739 /* PE session Id */
740 mlmDeauthCnf.sessionId = psessionEntry->peSessionId;
741
742 lim_post_sme_message(pMac,
743 LIM_MLM_DEAUTH_CNF,
744 (uint32_t *) &mlmDeauthCnf);
745 } else if ((mlmStaContext.cleanupTrigger ==
746 eLIM_PEER_ENTITY_DISASSOC) ||
747 (mlmStaContext.cleanupTrigger == eLIM_PEER_ENTITY_DEAUTH)) {
748 /**
749 * Received Disassociation/Deauthentication from peer.
750 * Issue Purge Ind to SME.
751 */
752 lim_log(pMac, LOGW,
753 FL("Lim Posting PURGE_STA_IND to Sme. Trigger: %d"),
754 mlmStaContext.cleanupTrigger);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530755 qdf_mem_copy((uint8_t *) &mlmPurgeStaInd.peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530756 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 mlmPurgeStaInd.reasonCode =
758 (uint8_t) mlmStaContext.disassocReason;
759 mlmPurgeStaInd.aid = staDsAssocId;
760 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
761 mlmPurgeStaInd.sessionId = psessionEntry->peSessionId;
762
763 lim_post_sme_message(pMac,
764 LIM_MLM_PURGE_STA_IND,
765 (uint32_t *) &mlmPurgeStaInd);
766 } else if (mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE) {
767 /* PE setup the peer entry in HW upfront, right after join is completed. */
768 /* If there is a failure during rest of the assoc sequence, this context needs to be cleaned up. */
769 uint8_t smesessionId;
770 uint16_t smetransactionId;
771
772 smesessionId = psessionEntry->smeSessionId;
773 smetransactionId = psessionEntry->transactionId;
774
775 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
776 MTRACE(mac_trace
777 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
778 psessionEntry->limSmeState));
779
780 /* if it is a reassoc failure to join new AP */
781 if ((mlmStaContext.resultCode ==
782 eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE)
783 || (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE)
784 || (mlmStaContext.resultCode ==
785 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE)) {
786 lim_log(pMac, LOG1,
787 FL("Lim Posting eWNI_SME_REASSOC_RSP to SME"
788 "resultCode: %d, statusCode: %d,"
789 "sessionId: %d"),
790 mlmStaContext.resultCode,
791 mlmStaContext.protStatusCode,
792 psessionEntry->peSessionId);
793
794 if (mlmStaContext.resultCode != eSIR_SME_SUCCESS) {
795 pe_delete_session(pMac, psessionEntry);
796 psessionEntry = NULL;
797 }
798
799 lim_send_sme_join_reassoc_rsp(pMac, eWNI_SME_REASSOC_RSP,
800 mlmStaContext.resultCode,
801 mlmStaContext.protStatusCode,
802 psessionEntry, smesessionId,
803 smetransactionId);
804 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_free(psessionEntry->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 psessionEntry->pLimJoinReq = NULL;
807
808 lim_log(pMac, LOG1,
809 FL("Lim Posting eWNI_SME_JOIN_RSP to SME."
810 "resultCode: %d,statusCode: %d,"
811 "sessionId: %d"),
812 mlmStaContext.resultCode,
813 mlmStaContext.protStatusCode,
814 psessionEntry->peSessionId);
815
816 if (mlmStaContext.resultCode != eSIR_SME_SUCCESS) {
817 pe_delete_session(pMac, psessionEntry);
818 psessionEntry = NULL;
819 }
820
821 lim_send_sme_join_reassoc_rsp(pMac, eWNI_SME_JOIN_RSP,
822 mlmStaContext.resultCode,
823 mlmStaContext.protStatusCode,
824 psessionEntry, smesessionId,
825 smetransactionId);
826 }
827
828 }
829
830 if (NULL != psessionEntry && !LIM_IS_AP_ROLE(psessionEntry)) {
831 pe_delete_session(pMac, psessionEntry);
832 psessionEntry = NULL;
833 }
834}
835
836/**
837 * lim_reject_association() - function to reject Re/Association Request
838 *
839 * @mac_ctx: pointer to global mac structure
840 * @peer_addr: mac address of the peer
841 * @sub_type: Indicates whether it is Association Request (=0) or
842 * Reassociation Request (=1) frame
843 * @add_pre_auth_context:Indicates whether pre-auth context
844 * to be added for this STA
845 * @auth_type: Indicates auth type to be added
846 * @sta_id: Indicates staId of the STA being rejected
847 * association
848 * @delete_sta: Indicates whether to delete STA context
849 * at Polaris
850 * @result_code: Indicates what reasonCode to be sent in
851 * Re/Assoc response to STA
852 * @session_entry: pointer to PE session
853 *
854 * This function is called whenever Re/Association Request need
855 * to be rejected due to failure in assigning an AID or failure
856 * in adding STA context at Polaris or reject by applications.
857 * Resources allocated if any are freedup and (Re) Association
858 * Response frame is sent to requesting STA. Pre-Auth context
859 * will be added for this STA if it does not exist already
860 *
861 * Return: none
862 */
863
864void
865lim_reject_association(tpAniSirGlobal mac_ctx, tSirMacAddr peer_addr,
866 uint8_t sub_type, uint8_t add_pre_auth_context,
867 tAniAuthType auth_type, uint16_t sta_id,
868 uint8_t delete_sta, tSirResultCodes result_code,
869 tpPESession session_entry)
870{
871 tpDphHashNode sta_ds;
872
873 lim_log(mac_ctx, LOG1,
874 FL("Sessionid: %d auth_type: %d sub_type: %d add_pre_auth_context: %d sta_id: %d delete_sta: %d result_code : %d peer_addr: " MAC_ADDRESS_STR),
875 session_entry->peSessionId, auth_type, sub_type,
876 add_pre_auth_context, sta_id, delete_sta, result_code,
877 MAC_ADDR_ARRAY(peer_addr));
878
879 if (add_pre_auth_context) {
880 /* Create entry for this STA in pre-auth list */
881 struct tLimPreAuthNode *auth_node;
882
883 auth_node = lim_acquire_free_pre_auth_node(mac_ctx,
884 &mac_ctx->lim.gLimPreAuthTimerTable);
885
886 if (auth_node) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530887 qdf_mem_copy((uint8_t *) auth_node->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 peer_addr, sizeof(tSirMacAddr));
889 auth_node->fTimerStarted = 0;
890 auth_node->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
891 auth_node->authType = (tAniAuthType) auth_type;
Anurag Chouhan210db072016-02-22 18:42:15 +0530892 auth_node->timestamp = qdf_mc_timer_get_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 lim_add_pre_auth_node(mac_ctx, auth_node);
894 }
895 }
896
897 if (delete_sta == false) {
898 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
899 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
900 1, peer_addr, sub_type, 0, session_entry);
901 /* Log error */
902 lim_log(mac_ctx, LOGW,
903 FL("received Re/Assoc req when max associated STAs reached from "));
904 lim_print_mac_addr(mac_ctx, peer_addr, LOGW);
905 lim_send_sme_max_assoc_exceeded_ntf(mac_ctx, peer_addr,
906 session_entry->smeSessionId);
907 return;
908 }
909
910 sta_ds = dph_get_hash_entry(mac_ctx, sta_id,
911 &session_entry->dph.dphHashTable);
912
913 if (sta_ds == NULL) {
914 lim_log(mac_ctx, LOGW,
915 FL("No STA context, yet rejecting Association"));
916 return;
917 }
918
919 /*
920 * Polaris has state for this STA.
921 * Trigger cleanup.
922 */
923 sta_ds->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
924
925 /* Receive path cleanup */
926 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
927
928 /*
929 * Send Re/Association Response with
930 * status code to requesting STA.
931 */
932 lim_send_assoc_rsp_mgmt_frame(mac_ctx, result_code, 0, peer_addr,
933 sub_type, 0, session_entry);
934
935 if (session_entry->parsedAssocReq[sta_ds->assocId] != NULL) {
936 uint8_t *assoc_req_frame;
937
938 assoc_req_frame = (uint8_t *)((tpSirAssocReq) (session_entry->
939 parsedAssocReq[sta_ds->assocId]))->assocReqFrame;
940 /*
941 *Assoction confirmation is complete,
942 *free the copy of association request frame.
943 */
944 if (assoc_req_frame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530945 qdf_mem_free(assoc_req_frame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 assoc_req_frame = NULL;
947 }
948
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530949 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
951 }
952}
953
954/**
955 * lim_decide_ap_protection_on_ht20_delete() - function to update protection
956 * parameters.
957 * @mac_ctx: pointer to global mac structure
958 * @sta_ds: station node
959 * @beacon_params: ap beacon parameters
960 * @session_entry: pe session entry
961 *
962 * protection related function while HT20 station is getting deleted.
963 *
964 * Return: none
965 */
966static void
967lim_decide_ap_protection_on_ht20_delete(tpAniSirGlobal mac_ctx,
968 tpDphHashNode sta_ds,
969 tpUpdateBeaconParams beacon_params,
970 tpPESession session_entry)
971{
972 uint32_t i = 0;
973
974 lim_log(mac_ctx, LOG1,
975 FL("(%d) A HT 20 STA is disassociated. Addr is %pM"),
976 session_entry->gLimHt20Params.numSta, sta_ds->staAddr);
977
978 if (session_entry->gLimHt20Params.numSta > 0) {
979 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
980 if (!session_entry->protStaCache[i].active)
981 continue;
982
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530983 if (!qdf_mem_cmp(session_entry->protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 sta_ds->staAddr, sizeof(tSirMacAddr))) {
985 session_entry->gLimHt20Params.numSta--;
986 session_entry->protStaCache[i].active =
987 false;
988 break;
989 }
990 }
991 }
992
993 if (session_entry->gLimHt20Params.numSta == 0) {
994 /* disable protection */
995 lim_log(mac_ctx, LOG1, FL("No 11B STA exists, PESessionID %d"),
996 session_entry->peSessionId);
997 lim_enable_ht20_protection(mac_ctx, false, false, beacon_params,
998 session_entry);
999 }
1000}
1001
1002/**
1003 * lim_decide_ap_protection_on_delete() - update SAP protection on station
1004 * deletion.
1005 * @mac_ctx: pointer to global mac structure
1006 * @sta_ds: station node
1007 * @beacon_params: ap beacon parameters
1008 * @session_entry: pe session entry
1009 *
1010 * Decides about protection related settings when a station is getting deleted.
1011 *
1012 * Return: none
1013 */
1014void
1015lim_decide_ap_protection_on_delete(tpAniSirGlobal mac_ctx,
1016 tpDphHashNode sta_ds,
1017 tpUpdateBeaconParams beacon_params,
1018 tpPESession session_entry)
1019{
1020 uint32_t phy_mode;
1021 tHalBitVal erp_enabled = eHAL_CLEAR;
1022 tSirRFBand rf_band = SIR_BAND_UNKNOWN;
1023 uint32_t i;
1024
1025 if (NULL == sta_ds)
1026 return;
1027
1028 lim_get_rf_band_new(mac_ctx, &rf_band, session_entry);
1029 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1030 erp_enabled = sta_ds->erpEnabled;
1031
1032 if ((SIR_BAND_5_GHZ == rf_band) &&
1033 (true == session_entry->htCapability) &&
1034 (session_entry->beaconParams.llaCoexist) &&
1035 (false == sta_ds->mlmStaContext.htCapability)) {
1036 /*
1037 * we are HT. if we are 11A, then protection is not required or
1038 * we are HT and 11A station is leaving.
1039 * protection consideration required.
1040 * HT station leaving ==> this case is commonly handled
1041 * between both the bands below.
1042 */
1043 lim_log(mac_ctx, LOG1,
1044 FL("(%d) A 11A STA is disassociated. Addr is %pM"),
1045 session_entry->gLim11aParams.numSta, sta_ds->staAddr);
1046 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1047 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301048 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 session_entry->protStaCache[i].addr,
1050 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301051 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 session_entry->protStaCache[i].active = false;
1053 break;
1054 }
1055 }
1056
1057 if (session_entry->gLim11aParams.numSta == 0) {
1058 /* disable protection */
1059 lim_update_11a_protection(mac_ctx, false, false,
1060 beacon_params, session_entry);
1061 }
1062 }
1063
1064 /* we are HT or 11G and 11B station is getting deleted */
1065 if ((SIR_BAND_2_4_GHZ == rf_band) &&
1066 (phy_mode == WNI_CFG_PHY_MODE_11G ||
1067 session_entry->htCapability) &&
1068 (erp_enabled == eHAL_CLEAR)) {
1069 lim_log(mac_ctx, LOG1,
1070 FL("(%d) A legacy STA is disassociated. Addr is %pM"),
1071 session_entry->gLim11bParams.numSta, sta_ds->staAddr);
1072 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1073 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301074 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 session_entry->protStaCache[i].addr,
1076 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301077 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 session_entry->gLim11bParams.numSta--;
1079 session_entry->protStaCache[i].active =
1080 false;
1081 break;
1082 }
1083 }
1084
1085 if (session_entry->gLim11bParams.numSta == 0) {
1086 /* disable protection */
1087 lim_enable11g_protection(mac_ctx, false, false,
1088 beacon_params, session_entry);
1089 }
1090 }
1091
1092 /*
1093 * we are HT AP and non-11B station is leaving.
1094 * 11g station is leaving
1095 */
1096 if ((SIR_BAND_2_4_GHZ == rf_band) &&
1097 session_entry->htCapability &&
1098 !sta_ds->mlmStaContext.htCapability) {
1099 lim_log(mac_ctx, LOG1,
1100 FL("(%d) A 11g STA is disassociated. Addr is %pM"),
1101 session_entry->gLim11bParams.numSta, sta_ds->staAddr);
1102 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1103 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301104 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 session_entry->protStaCache[i].addr,
1106 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301107 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 session_entry->gLim11gParams.numSta--;
1109 session_entry->protStaCache[i].active = false;
1110 break;
1111 }
1112 }
1113
1114 if (session_entry->gLim11gParams.numSta == 0) {
1115 /* disable protection */
1116 lim_enable_ht_protection_from11g(mac_ctx, false, false,
1117 beacon_params,
1118 session_entry);
1119 }
1120 }
1121
1122 if (!((true == session_entry->htCapability) &&
1123 (true == sta_ds->mlmStaContext.htCapability)))
1124 return;
1125
1126 /*
1127 * Applies to 2.4 as well as 5 GHZ.
1128 * HT non-GF leaving
1129 */
1130 if (!sta_ds->htGreenfield) {
1131 lim_log(mac_ctx, LOG1,
1132 FL("(%d) A non-GF STA is disassociated. Addr is %pM"),
1133 session_entry->gLimNonGfParams.numSta, sta_ds->staAddr);
1134 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1135 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301136 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 session_entry->protStaCache[i].addr,
1138 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301139 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 session_entry->protStaCache[i].active = false;
1141 break;
1142 }
1143 }
1144
1145 if (session_entry->gLimNonGfParams.numSta == 0) {
1146 /* disable protection */
1147 lim_enable_ht_non_gf_protection(mac_ctx, false, false,
1148 beacon_params, session_entry);
1149 }
1150 }
1151
1152 /*
1153 * Applies to 2.4 as well as 5 GHZ.
1154 * HT 20Mhz station leaving
1155 */
1156 if (session_entry->beaconParams.ht20Coexist &&
1157 (eHT_CHANNEL_WIDTH_20MHZ ==
1158 sta_ds->htSupportedChannelWidthSet)) {
1159 lim_decide_ap_protection_on_ht20_delete(mac_ctx, sta_ds,
1160 beacon_params, session_entry);
1161 }
1162
1163 /*
1164 * Applies to 2.4 as well as 5 GHZ.
1165 * LSIG TXOP not supporting staiton leaving
1166 */
1167 if ((false == session_entry->beaconParams.
1168 fLsigTXOPProtectionFullSupport) &&
1169 (false == sta_ds->htLsigTXOPProtection)) {
1170 lim_log(mac_ctx, LOG1,
1171 FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is %pM"),
1172 session_entry->gLimLsigTxopParams.numSta,
1173 sta_ds->staAddr);
1174 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1175 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301176 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 session_entry->protStaCache[i].addr,
1178 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301179 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 session_entry->protStaCache[i].active = false;
1181 break;
1182 }
1183 }
1184
1185 if (session_entry->gLimLsigTxopParams.numSta == 0) {
1186 /* disable protection */
1187 lim_enable_ht_lsig_txop_protection(mac_ctx, true,
1188 false, beacon_params, session_entry);
1189 }
1190 }
1191}
1192
1193/**
1194 * lim_decide_short_preamble() - update short preamble parameters
1195 * @mac_ctx: pointer to global mac structure
1196 * @sta_ds: station node
1197 * @beacon_params: ap beacon parameters
1198 * @session_entry: pe session entry
1199 *
1200 * Decides about any short preamble related change because of new station
1201 * joining.
1202 *
1203 * Return: None
1204 */
1205void lim_decide_short_preamble(tpAniSirGlobal mac_ctx,
1206 tpDphHashNode sta_ds,
1207 tpUpdateBeaconParams beacon_params,
1208 tpPESession session_entry)
1209{
1210 uint32_t i;
1211
1212 if (sta_ds->shortPreambleEnabled == eHAL_CLEAR) {
1213 lim_log(mac_ctx, LOG1,
1214 FL("(%d) A non-short preamble STA is disassociated. Addr is %pM"),
1215 session_entry->gLimNoShortParams.numNonShortPreambleSta,
1216 sta_ds->staAddr);
1217 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1218 if (session_entry->gLimNoShortParams.
1219 staNoShortCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301220 (!qdf_mem_cmp(session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 gLimNoShortParams.
1222 staNoShortCache[i].addr,
1223 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301224 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 session_entry->gLimNoShortParams.
1226 numNonShortPreambleSta--;
1227 session_entry->gLimNoShortParams.
1228 staNoShortCache[i].active = false;
1229 break;
1230 }
1231 }
1232
1233 if (session_entry->gLimNoShortParams.numNonShortPreambleSta)
1234 return;
1235
1236 /*
1237 * enable short preamble
1238 * reset the cache
1239 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301240 qdf_mem_set((uint8_t *) &session_entry->gLimNoShortParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 sizeof(tLimNoShortParams), 0);
1242 if (lim_enable_short_preamble(mac_ctx, true,
1243 beacon_params, session_entry) != eSIR_SUCCESS) {
1244 lim_log(mac_ctx, LOGE,
1245 FL("Cannot enable short preamble"));
1246 }
1247 }
1248}
1249
1250/**
1251 * lim_decide_short_slot() - update short slot time related parameters
1252 * @mac_ctx: pointer to global mac structure
1253 * @sta_ds: station node
1254 * @beacon_params: ap beacon parameters
1255 * @session_entry: pe session entry
1256 *
1257 * Decides about any short slot time related change because of station leaving
1258 * the BSS.
1259 * Return: None
1260 */
1261void
1262lim_decide_short_slot(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds,
1263 tpUpdateBeaconParams beacon_params,
1264 tpPESession session_entry)
1265{
1266 uint32_t i, val, non_short_slot_sta_count;
1267
1268 if (sta_ds->shortSlotTimeEnabled != eHAL_CLEAR)
1269 return;
1270
1271 lim_log(mac_ctx, LOG1,
1272 FL("(%d) A non-short slottime STA is disassociated. Addr is %pM"),
1273 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta,
1274 sta_ds->staAddr);
1275
1276 wlan_cfg_get_int(mac_ctx, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED,
1277 &val);
1278
1279 if (LIM_IS_AP_ROLE(session_entry)) {
1280 non_short_slot_sta_count =
1281 session_entry->gLimNoShortSlotParams.numNonShortSlotSta;
1282 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1283 if (session_entry->gLimNoShortSlotParams.
1284 staNoShortSlotCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301285 (!qdf_mem_cmp(session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 gLimNoShortSlotParams.
1287 staNoShortSlotCache[i].addr,
1288 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301289 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 non_short_slot_sta_count--;
1291 session_entry->gLimNoShortSlotParams.
1292 staNoShortSlotCache[i].active = false;
1293 break;
1294 }
1295 }
1296
1297 if (non_short_slot_sta_count == 0 && val) {
1298 /*
1299 * enable short slot time
1300 * reset the cache
1301 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301302 qdf_mem_set((uint8_t *) &session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 gLimNoShortSlotParams,
1304 sizeof(tLimNoShortSlotParams), 0);
1305 beacon_params->fShortSlotTime = true;
1306 beacon_params->paramChangeBitmap |=
1307 PARAM_SHORT_SLOT_TIME_CHANGED;
1308 session_entry->shortSlotTimeSupported = true;
1309 }
1310 session_entry->gLimNoShortSlotParams.numNonShortSlotSta =
1311 non_short_slot_sta_count;
1312 } else {
1313 non_short_slot_sta_count =
1314 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta;
1315 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1316 if (mac_ctx->lim.gLimNoShortSlotParams.
1317 staNoShortSlotCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301318 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 mac_ctx->lim.gLimNoShortSlotParams.
1320 staNoShortSlotCache[i].addr,
1321 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301322 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 non_short_slot_sta_count--;
1324 mac_ctx->lim.gLimNoShortSlotParams.
1325 staNoShortSlotCache[i].active = false;
1326 break;
1327 }
1328 }
1329
1330 if (val && !non_short_slot_sta_count) {
1331 /*
1332 * enable short slot time
1333 * reset the cache
1334 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301335 qdf_mem_set(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 (uint8_t *) &mac_ctx->lim.gLimNoShortSlotParams,
1337 sizeof(tLimNoShortSlotParams), 0);
1338 /*in case of AP set SHORT_SLOT_TIME to enable*/
1339 if (LIM_IS_AP_ROLE(session_entry)) {
1340 beacon_params->fShortSlotTime = true;
1341 beacon_params->paramChangeBitmap |=
1342 PARAM_SHORT_SLOT_TIME_CHANGED;
1343 session_entry->shortSlotTimeSupported = true;
1344 }
1345 }
1346 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta =
1347 non_short_slot_sta_count;
1348 }
1349}
1350
1351void
1352lim_post_reassoc_failure(tpAniSirGlobal pMac,
1353 tSirResultCodes resultCode,
1354 uint16_t protStatusCode, tpPESession psessionEntry)
1355{
1356 tLimMlmReassocCnf mlmReassocCnf;
1357
1358 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1359 MTRACE(mac_trace
1360 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
1361 eLIM_MLM_LINK_ESTABLISHED_STATE));
1362
1363 /* 'Change' timer for future activations */
1364 lim_deactivate_and_change_timer(pMac, eLIM_REASSOC_FAIL_TIMER);
1365
1366 mlmReassocCnf.resultCode = resultCode;
1367 mlmReassocCnf.protStatusCode = protStatusCode;
1368 /* Update PE session Id */
1369 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1370 lim_post_sme_message(pMac,
1371 LIM_MLM_REASSOC_CNF, (uint32_t *) &mlmReassocCnf);
1372} /*** end lim_post_reassoc_failure() ***/
1373
1374/**
1375 * lim_restore_pre_reassoc_state()
1376 *
1377 ***FUNCTION:
1378 * This function is called on STA role whenever Reasociation
1379 * Response with a reject code is received from AP.
1380 *
1381 ***LOGIC:
1382 * Reassociation failure timer is stopped, Old (or current) AP's
1383 * context is restored both at Polaris & software
1384 *
1385 ***ASSUMPTIONS:
1386 *
1387 ***NOTE:
1388 *
1389 * @param pMac - Pointer to Global MAC structure
1390 * @param resultCode - Result code that specifies why Reassociation
1391 * attemp failed
1392 *
1393 * @return None
1394 */
1395
1396void
1397lim_restore_pre_reassoc_state(tpAniSirGlobal pMac,
1398 tSirResultCodes resultCode,
1399 uint16_t protStatusCode, tpPESession psessionEntry)
1400{
1401 tLimMlmReassocCnf mlmReassocCnf;
1402
1403 lim_log(pMac, LOG1,
1404 FL("sessionid: %d protStatusCode: %d resultCode: %d"),
1405 psessionEntry->smeSessionId, protStatusCode, resultCode);
1406
1407 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1408 MTRACE(mac_trace
1409 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
1410 eLIM_MLM_LINK_ESTABLISHED_STATE));
1411
1412 /* 'Change' timer for future activations */
1413 lim_deactivate_and_change_timer(pMac, eLIM_REASSOC_FAIL_TIMER);
1414
1415 lim_set_channel(pMac, psessionEntry->currentOperChannel,
1416 psessionEntry->ch_center_freq_seg0,
1417 psessionEntry->ch_center_freq_seg1,
1418 psessionEntry->ch_width,
1419 psessionEntry->maxTxPower,
1420 psessionEntry->peSessionId);
1421
1422 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1423
1424 mlmReassocCnf.resultCode = resultCode;
1425 mlmReassocCnf.protStatusCode = protStatusCode;
1426 /* Update PE session Id */
1427 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1428 lim_post_sme_message(pMac,
1429 LIM_MLM_REASSOC_CNF, (uint32_t *) &mlmReassocCnf);
1430} /*** end lim_restore_pre_reassoc_state() ***/
1431
1432/**
1433 * lim_is_reassoc_in_progress()
1434 *
1435 ***FUNCTION:
1436 * This function is called to see if STA is in wt-reassoc-rsp state.
1437 *
1438 ***LOGIC:
1439 *
1440 ***ASSUMPTIONS:
1441 *
1442 ***NOTE:
1443 *
1444 * @param pMac - Pointer to Global MAC structure
1445 *
1446 * @return true When STA is waiting for Reassoc response from AP \n
1447 * else false
1448 */
1449
1450bool lim_is_reassoc_in_progress(tpAniSirGlobal pMac, tpPESession psessionEntry)
1451{
1452 if (psessionEntry == NULL) {
1453 return false;
1454 }
1455 if ((LIM_IS_STA_ROLE(psessionEntry) ||
1456 LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) &&
1457 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1458 (psessionEntry->limSmeState ==
1459 eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1460 return true;
1461
1462 return false;
1463} /*** end lim_is_reassoc_in_progress() ***/
1464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465/**
1466 * lim_populate_vht_mcs_set - function to populate vht mcs rate set
1467 * @mac_ctx: pointer to global mac structure
1468 * @rates: pointer to supported rate set
1469 * @peer_vht_caps: pointer to peer vht capabilities
1470 * @session_entry: pe session entry
1471 *
1472 * Populates vht mcs rate set based on peer and self capabilities
1473 *
1474 * Return: eSIR_SUCCESS on success else eSIR_FAILURE
1475 */
1476tSirRetStatus lim_populate_vht_mcs_set(tpAniSirGlobal mac_ctx,
1477 tpSirSupportedRates rates,
1478 tDot11fIEVHTCaps *peer_vht_caps,
1479 tpPESession session_entry)
1480{
1481 uint32_t val;
1482 uint32_t self_sta_dot11mode = 0;
1483 uint16_t mcs_map_mask = MCSMAPMASK1x1;
1484 uint16_t mcs_map_mask2x2 = 0;
1485
1486 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_sta_dot11mode);
1487
1488 if (!IS_DOT11_MODE_VHT(self_sta_dot11mode))
1489 return eSIR_SUCCESS;
1490
1491 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RX_MCS_MAP, &val) !=
1492 eSIR_SUCCESS) {
1493 lim_log(mac_ctx, LOGE, FL("could not retrieve VHT RX MCS MAP"));
1494 goto error;
1495 }
1496 rates->vhtRxMCSMap = (uint16_t) val;
1497
1498 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TX_MCS_MAP, &val) !=
1499 eSIR_SUCCESS) {
1500 lim_log(mac_ctx, LOGE, FL("could not retrieve VHT TX MCS MAP"));
1501 goto error;
1502 }
1503 rates->vhtTxMCSMap = (uint16_t) val;
1504
1505 if (wlan_cfg_get_int(mac_ctx,
1506 WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,
1507 &val) != eSIR_SUCCESS) {
1508 lim_log(mac_ctx, LOGE,
1509 FL("couldn't retrieve VHT RX Supported data rate MAP"));
1510 goto error;
1511 }
1512 rates->vhtRxHighestDataRate = (uint16_t) val;
1513
1514 if (wlan_cfg_get_int(mac_ctx,
1515 WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,
1516 &val) != eSIR_SUCCESS) {
1517 lim_log(mac_ctx, LOGE,
1518 FL("couldn't retrieve VHT RX Supported data rate MAP"));
1519 goto error;
1520 }
1521 rates->vhtTxHighestDataRate = (uint16_t) val;
1522
1523 if (peer_vht_caps == NULL)
1524 return eSIR_SUCCESS;
1525
1526 rates->vhtTxHighestDataRate =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301527 QDF_MIN(rates->vhtTxHighestDataRate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 peer_vht_caps->txSupDataRate);
1529 rates->vhtRxHighestDataRate =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301530 QDF_MIN(rates->vhtRxHighestDataRate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 peer_vht_caps->rxHighSupDataRate);
1532
1533 if (mac_ctx->roam.configParam.enable2x2) {
1534 if (session_entry && mac_ctx->lteCoexAntShare &&
1535 IS_24G_CH(session_entry->currentOperChannel)) {
1536 if (IS_2X2_CHAIN(session_entry->chainMask))
1537 mcs_map_mask2x2 = MCSMAPMASK2x2;
1538 else
1539 lim_log(mac_ctx, LOGE, FL("2x2 not enabled %d"),
1540 session_entry->chainMask);
1541 } else {
1542 mcs_map_mask2x2 = MCSMAPMASK2x2;
1543 }
1544 }
1545
1546 if ((peer_vht_caps->txMCSMap & mcs_map_mask) <
1547 (rates->vhtRxMCSMap & mcs_map_mask)) {
1548 rates->vhtRxMCSMap &= ~(mcs_map_mask);
1549 rates->vhtRxMCSMap |=
1550 (peer_vht_caps->txMCSMap & mcs_map_mask);
1551 }
1552 if ((peer_vht_caps->rxMCSMap & mcs_map_mask) <
1553 (rates->vhtTxMCSMap & mcs_map_mask)) {
1554 rates->vhtTxMCSMap &= ~(mcs_map_mask);
1555 rates->vhtTxMCSMap |=
1556 (peer_vht_caps->rxMCSMap & mcs_map_mask);
1557 }
1558
1559 if (mcs_map_mask2x2) {
1560
1561 uint16_t peer_mcs_map, self_mcs_map;
1562
1563 peer_mcs_map =
1564 peer_vht_caps->txMCSMap & mcs_map_mask2x2;
1565 self_mcs_map =
1566 rates->vhtRxMCSMap & mcs_map_mask2x2;
1567
1568 if ((self_mcs_map != mcs_map_mask2x2) &&
1569 ((peer_mcs_map == mcs_map_mask2x2) ||
1570 (peer_mcs_map < self_mcs_map))) {
1571 rates->vhtRxMCSMap &= ~mcs_map_mask2x2;
1572 rates->vhtRxMCSMap |= peer_mcs_map;
1573 }
1574
1575 peer_mcs_map =
1576 (peer_vht_caps->rxMCSMap & mcs_map_mask2x2);
1577 self_mcs_map =
1578 (rates->vhtTxMCSMap & mcs_map_mask2x2);
1579
1580 if ((self_mcs_map != mcs_map_mask2x2) &&
1581 ((peer_mcs_map == mcs_map_mask2x2) ||
1582 (peer_mcs_map < self_mcs_map))) {
1583 rates->vhtTxMCSMap &= ~mcs_map_mask2x2;
1584 rates->vhtTxMCSMap |= peer_mcs_map;
1585 }
1586 }
1587
1588 lim_log(mac_ctx, LOG1,
1589 FL("enable2x2 - %d vhtRxMCSMap - %x vhtTxMCSMap - %x\n"),
1590 mac_ctx->roam.configParam.enable2x2,
1591 rates->vhtRxMCSMap, rates->vhtTxMCSMap);
1592
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001593 if (NULL != session_entry) {
1594 session_entry->supported_nss_1x1 =
1595 ((rates->vhtTxMCSMap & VHT_MCS_1x1) ==
1596 VHT_MCS_1x1) ? true : false;
1597 lim_log(mac_ctx, LOG1,
1598 FL("VHT supported nss 1x1: %d"),
1599 session_entry->supported_nss_1x1);
1600 }
1601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 return eSIR_SUCCESS;
1603error:
1604
1605 return eSIR_FAILURE;
1606}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607
1608/**
1609 * lim_populate_own_rate_set() - comprises the basic and extended rates read
1610 * from CFG
1611 * @mac_ctx: pointer to global mac structure
1612 * @rates: pointer to supported rates
1613 * @supported_mcs_set: pointer to supported mcs rates
1614 * @basic_only: update only basic rates if set true
1615 * @session_entry: pe session entry
1616 * @vht_caps: pointer to vht capability
1617 *
1618 * This function is called by limProcessAssocRsp() or
1619 * lim_add_staInIBSS()
1620 * - It creates a combined rate set of 12 rates max which
1621 * comprises the basic and extended rates read from CFG
1622 * - It sorts the combined rate Set and copy it in the
1623 * rate array of the pSTA descriptor
1624 * - It sets the erpEnabled bit of the STA descriptor
1625 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1626 * an A rate in the supported or extended rate sets
1627 *
1628 * Return: eSIR_SUCCESS or eSIR_FAILURE.
1629 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630tSirRetStatus
1631lim_populate_own_rate_set(tpAniSirGlobal mac_ctx,
1632 tpSirSupportedRates rates, uint8_t *supported_mcs_set,
1633 uint8_t basic_only, tpPESession session_entry,
1634 tDot11fIEVHTCaps *vht_caps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635{
1636 tSirMacRateSet temp_rate_set;
1637 tSirMacRateSet temp_rate_set2;
1638 uint32_t i, j, val, min, is_arate;
1639 uint32_t phy_mode = 0;
1640 uint32_t self_sta_dot11mode = 0;
1641 uint8_t a_rate_index = 0;
1642 uint8_t b_rate_index = 0;
1643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 is_arate = 0;
1645
1646 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_sta_dot11mode);
1647 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1648
1649 /*
1650 * Include 11b rates only when the device configured in
1651 * auto, 11a/b/g or 11b_only
1652 */
1653 if ((self_sta_dot11mode == WNI_CFG_DOT11_MODE_ALL) ||
1654 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1655 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11AC) ||
1656 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11N) ||
1657 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1658 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11B)) {
1659 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1660 wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_RATES_11B,
1661 (uint8_t *) &temp_rate_set.rate, &val);
1662 temp_rate_set.numRates = (uint8_t) val;
1663 } else {
1664 temp_rate_set.numRates = 0;
1665 }
1666
1667 /* Include 11a rates when the device configured in non-11b mode */
1668 if (!IS_DOT11_MODE_11B(self_sta_dot11mode)) {
1669 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1670 wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_RATES_11A,
1671 (uint8_t *) &temp_rate_set2.rate, &val);
1672 temp_rate_set2.numRates = (uint8_t) val;
1673 } else {
1674 temp_rate_set2.numRates = 0;
1675 }
1676
1677 if ((temp_rate_set.numRates + temp_rate_set2.numRates) > 12) {
1678 /* we are in big trouble */
1679 lim_log(mac_ctx, LOGP, FL("more than 12 rates in CFG"));
1680 /* panic */
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001681 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 }
1683 /* copy all rates in temp_rate_set, there are 12 rates max */
1684 for (i = 0; i < temp_rate_set2.numRates; i++)
1685 temp_rate_set.rate[i + temp_rate_set.numRates] =
1686 temp_rate_set2.rate[i];
1687
1688 temp_rate_set.numRates += temp_rate_set2.numRates;
1689
1690 /**
1691 * Sort rates in temp_rate_set (they are likely to be already sorted)
1692 * put the result in pSupportedRates
1693 */
1694
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301695 qdf_mem_set((uint8_t *) rates, sizeof(tSirSupportedRates), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 for (i = 0; i < temp_rate_set.numRates; i++) {
1697 min = 0;
1698 val = 0xff;
1699 is_arate = 0;
1700
1701 for (j = 0; (j < temp_rate_set.numRates) &&
1702 (j < SIR_MAC_RATESET_EID_MAX); j++) {
1703 if ((uint32_t) (temp_rate_set.rate[j] & 0x7f) <
1704 val) {
1705 val = temp_rate_set.rate[j] & 0x7f;
1706 min = j;
1707 }
1708 }
1709
1710 if (sirIsArate(temp_rate_set.rate[min] & 0x7f))
1711 is_arate = 1;
1712
1713 /*
1714 * HAL needs to know whether the rate is basic rate or
1715 * not, as it needs to update the response rate table
1716 * accordingly. e.g. if one of the 11a rates is
1717 * basic rate, then that rate can be used for sending
1718 * control frames.
1719 * HAL updates the response rate table whenever basic
1720 * rate set is changed.
1721 */
1722 if (basic_only && temp_rate_set.rate[min] & 0x80) {
1723 if (is_arate)
1724 rates->llaRates[a_rate_index++] =
1725 temp_rate_set.rate[min];
1726 else
1727 rates->llbRates[b_rate_index++] =
1728 temp_rate_set.rate[min];
1729 } else {
1730 if (is_arate)
1731 rates->llaRates[a_rate_index++] =
1732 temp_rate_set.rate[min];
1733 else
1734 rates->llbRates[b_rate_index++] =
1735 temp_rate_set.rate[min];
1736 }
1737 temp_rate_set.rate[min] = 0xff;
1738 }
1739
1740 if (IS_DOT11_MODE_HT(self_sta_dot11mode)) {
1741 val = SIZE_OF_SUPPORTED_MCS_SET;
1742 if (wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_MCS_SET,
1743 rates->supportedMCSSet,
1744 &val) != eSIR_SUCCESS) {
1745 /* Could not get rateset from CFG. Log error. */
1746 lim_log(mac_ctx, LOGE,
1747 FL("could not retrieve supportedMCSSet"));
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001748 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 }
1750
1751 /*
1752 * if supported MCS Set of the peer is passed in,
1753 * then do the intersection
1754 * else use the MCS set from local CFG.
1755 */
1756
1757 if (supported_mcs_set != NULL) {
1758 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1759 rates->supportedMCSSet[i] &=
1760 supported_mcs_set[i];
1761 }
1762
1763 lim_log(mac_ctx, LOG2, FL("MCS Rate Set Bitmap: "));
1764 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1765 PELOG2(lim_log(mac_ctx, LOG2, FL("%x "),
1766 rates->supportedMCSSet[i]);)
1767 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 lim_populate_vht_mcs_set(mac_ctx, rates, vht_caps, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769
1770 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771}
1772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773tSirRetStatus
1774lim_populate_peer_rate_set(tpAniSirGlobal pMac,
1775 tpSirSupportedRates pRates,
1776 uint8_t *pSupportedMCSSet,
1777 uint8_t basicOnly,
1778 tpPESession psessionEntry, tDot11fIEVHTCaps *pVHTCaps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779{
1780 tSirMacRateSet tempRateSet;
1781 tSirMacRateSet tempRateSet2;
1782 uint32_t i, j, val, min, isArate;
1783 isArate = 0;
1784
1785 /* copy operational rate set from psessionEntry */
1786 if (psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301787 qdf_mem_copy((uint8_t *) tempRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 (uint8_t *) (psessionEntry->rateSet.rate),
1789 psessionEntry->rateSet.numRates);
1790 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1791 } else {
1792 lim_log(pMac, LOGE,
1793 FL("more than SIR_MAC_RATESET_EID_MAX rates\n"));
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001794 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 }
1796 if ((psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1797 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1798 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11AC) ||
1799 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11N)) {
1800 if (psessionEntry->extRateSet.numRates <=
1801 SIR_MAC_RATESET_EID_MAX) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301802 qdf_mem_copy((uint8_t *) tempRateSet2.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 (uint8_t *) (psessionEntry->extRateSet.
1804 rate),
1805 psessionEntry->extRateSet.numRates);
1806 tempRateSet2.numRates =
1807 psessionEntry->extRateSet.numRates;
1808 } else {
1809 lim_log(pMac, LOGE,
1810 FL
1811 ("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates\n"));
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001812 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 }
1814 } else
1815 tempRateSet2.numRates = 0;
1816 if ((tempRateSet.numRates + tempRateSet2.numRates) >
1817 SIR_MAC_RATESET_EID_MAX) {
1818 /* we are in big trouble */
1819 lim_log(pMac, LOGP, FL("more than 12 rates in CFG"));
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001820 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 }
1822
1823 /* copy all rates in tempRateSet, there are 12 rates max */
1824 for (i = 0; i < tempRateSet2.numRates; i++)
1825 tempRateSet.rate[i + tempRateSet.numRates] =
1826 tempRateSet2.rate[i];
1827 tempRateSet.numRates += tempRateSet2.numRates;
1828 /**
1829 * Sort rates in tempRateSet (they are likely to be already sorted)
1830 * put the result in pSupportedRates
1831 */
1832 {
1833 uint8_t aRateIndex = 0;
1834 uint8_t bRateIndex = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301835 qdf_mem_set((uint8_t *) pRates, sizeof(tSirSupportedRates), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 for (i = 0; i < tempRateSet.numRates; i++) {
1837 min = 0;
1838 val = 0xff;
1839 isArate = 0;
1840 for (j = 0;
1841 (j < tempRateSet.numRates)
1842 && (j < SIR_MAC_RATESET_EID_MAX); j++) {
1843 if ((uint32_t) (tempRateSet.rate[j] & 0x7f) <
1844 val) {
1845 val = tempRateSet.rate[j] & 0x7f;
1846 min = j;
1847 }
1848 }
1849 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1850 isArate = 1;
1851 /*
1852 * HAL needs to know whether the rate is basic rate or not, as it needs to
1853 * update the response rate table accordingly. e.g. if one of the 11a rates is
1854 * basic rate, then that rate can be used for sending control frames.
1855 * HAL updates the response rate table whenever basic rate set is changed.
1856 */
1857 if (basicOnly) {
1858 if (tempRateSet.rate[min] & 0x80) {
1859 if (isArate)
1860 pRates->llaRates[aRateIndex++] =
1861 tempRateSet.rate[min];
1862 else
1863 pRates->llbRates[bRateIndex++] =
1864 tempRateSet.rate[min];
1865 }
1866 } else {
1867 if (isArate)
1868 pRates->llaRates[aRateIndex++] =
1869 tempRateSet.rate[min];
1870 else
1871 pRates->llbRates[bRateIndex++] =
1872 tempRateSet.rate[min];
1873 }
1874 tempRateSet.rate[min] = 0xff;
1875 }
1876 }
1877
1878 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)) {
1879 val = SIZE_OF_SUPPORTED_MCS_SET;
1880 if (wlan_cfg_get_str(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1881 pRates->supportedMCSSet,
1882 &val) != eSIR_SUCCESS) {
1883 /* / Could not get rateset from CFG. Log error. */
1884 PELOGE(lim_log
1885 (pMac, LOGE,
1886 FL("could not retrieve supportedMCSSet"));
1887 )
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001888 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 }
1890 /* if supported MCS Set of the peer is passed in, then do the intersection */
1891 /* else use the MCS set from local CFG. */
1892 if (pSupportedMCSSet != NULL) {
1893 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1894 pRates->supportedMCSSet[i] &=
1895 pSupportedMCSSet[i];
1896 }
1897 PELOG2(lim_log(pMac, LOG2, FL("MCS Rate Set Bitmap: "));)
1898 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1899 PELOG2(lim_log
1900 (pMac, LOG2, FL("%x "),
1901 pRates->supportedMCSSet[i]);
1902 )
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001903
1904 psessionEntry->supported_nss_1x1 =
1905 ((pRates->supportedMCSSet[1] != 0) ? false : true);
1906 PELOG1(lim_log(pMac, LOG1, FL("HT supported nss 1x1: %d"),
1907 psessionEntry->supported_nss_1x1);)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 lim_populate_vht_mcs_set(pMac, pRates, pVHTCaps, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911} /*** lim_populate_peer_rate_set() ***/
1912
1913/**
1914 * lim_populate_matching_rate_set() -process the CFG rate sets and
1915 * the rate sets received in the Assoc request on AP.
1916 * @mac_ctx: pointer to global mac structure
1917 * @sta_ds: station node
1918 * @oper_rate_set: pointer to operating rate set
1919 * @ext_rate_set: pointer to extended rate set
1920 * @supported_mcs_set: pointer to supported rate set
1921 * @session_entry: pointer to pe session entry
1922 * @vht_caps: pointer to vht capabilities
1923 *
1924 * This is called at the time of Association Request
1925 * processing on AP and while adding peer's context
1926 * in IBSS role to process the CFG rate sets and
1927 * the rate sets received in the Assoc request on AP
1928 * or Beacon/Probe Response from peer in IBSS.
1929 *
1930 * 1. It makes the intersection between our own rate Sat
1931 * and extemcded rate set and the ones received in the
1932 * association request.
1933 * 2. It creates a combined rate set of 12 rates max which
1934 * comprised the basic and extended rates
1935 * 3. It sorts the combined rate Set and copy it in the
1936 * rate array of the pSTA descriptor
1937 *
1938 * The parser has already ensured unicity of the rates in the
1939 * association request structure
1940 *
1941 * Return: eSIR_SUCCESS on success else eSIR_FAILURE
1942 */
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001943tSirRetStatus lim_populate_matching_rate_set(tpAniSirGlobal mac_ctx,
1944 tpDphHashNode sta_ds,
1945 tSirMacRateSet *oper_rate_set,
1946 tSirMacRateSet *ext_rate_set,
1947 uint8_t *supported_mcs_set,
1948 tpPESession session_entry,
1949 tDot11fIEVHTCaps *vht_caps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950{
1951 tSirMacRateSet temp_rate_set;
1952 tSirMacRateSet temp_rate_set2;
1953 uint32_t i, j, val, min, is_arate;
1954 uint32_t phy_mode;
1955 uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET];
1956 tpSirSupportedRates rates;
1957 uint8_t a_rate_index = 0;
1958 uint8_t b_rate_index = 0;
1959
1960 is_arate = 0;
1961
1962 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1963
1964 /* copy operational rate set from session_entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301965 qdf_mem_copy((temp_rate_set.rate), (session_entry->rateSet.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 session_entry->rateSet.numRates);
1967 temp_rate_set.numRates = (uint8_t) session_entry->rateSet.numRates;
1968
1969 if (phy_mode == WNI_CFG_PHY_MODE_11G) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301970 qdf_mem_copy((temp_rate_set2.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 (session_entry->extRateSet.rate),
1972 session_entry->extRateSet.numRates);
1973 temp_rate_set2.numRates =
1974 (uint8_t) session_entry->extRateSet.numRates;
1975 } else {
1976 temp_rate_set2.numRates = 0;
1977 }
1978
1979 if ((temp_rate_set.numRates + temp_rate_set2.numRates) > 12) {
1980 lim_log(mac_ctx, LOGE, FL("more than 12 rates in CFG"));
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001981 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 }
1983
1984 /*
1985 * Handling of the rate set IEs is the following:
1986 * - keep only rates that we support and that the station supports
1987 * - sort and the rates into the pSta->rate array
1988 */
1989
1990 /* Copy all rates in temp_rate_set, there are 12 rates max */
1991 for (i = 0; i < temp_rate_set2.numRates; i++)
1992 temp_rate_set.rate[i + temp_rate_set.numRates] =
1993 temp_rate_set2.rate[i];
1994
1995 temp_rate_set.numRates += temp_rate_set2.numRates;
1996
1997 /*
1998 * Sort rates in temp_rate_set (they are likely to be already sorted)
1999 * put the result in temp_rate_set2
2000 */
2001 temp_rate_set2.numRates = 0;
2002
2003 for (i = 0; i < temp_rate_set.numRates; i++) {
2004 min = 0;
2005 val = 0xff;
2006
2007 for (j = 0; j < temp_rate_set.numRates; j++)
2008 if ((uint32_t) (temp_rate_set.rate[j] & 0x7f) < val) {
2009 val = temp_rate_set.rate[j] & 0x7f;
2010 min = j;
2011 }
2012
2013 temp_rate_set2.rate[temp_rate_set2.numRates++] =
2014 temp_rate_set.rate[min];
2015 temp_rate_set.rate[min] = 0xff;
2016 }
2017
2018 /*
2019 * Copy received rates in temp_rate_set, the parser has ensured
2020 * unicity of the rates so there cannot be more than 12
2021 */
2022 for (i = 0; (i < oper_rate_set->numRates &&
2023 i < SIR_MAC_RATESET_EID_MAX); i++)
2024 temp_rate_set.rate[i] = oper_rate_set->rate[i];
2025
2026 temp_rate_set.numRates = oper_rate_set->numRates;
2027
2028 lim_log(mac_ctx, LOG2,
2029 "Sum of SUPPORTED and EXTENDED Rate Set (%1d)",
2030 temp_rate_set.numRates + ext_rate_set->numRates);
2031
2032 if (ext_rate_set->numRates &&
2033 ((temp_rate_set.numRates + ext_rate_set->numRates) > 12) &&
2034 temp_rate_set.numRates < 12) {
2035 int found = 0;
2036 int tail = temp_rate_set.numRates;
2037
2038 for (i = 0; (i < ext_rate_set->numRates &&
2039 i < SIR_MAC_RATESET_EID_MAX); i++) {
2040 found = 0;
2041 for (j = 0; j < (uint32_t) tail; j++) {
2042 if ((temp_rate_set.rate[j] & 0x7F) ==
2043 (ext_rate_set->rate[i] & 0x7F)) {
2044 found = 1;
2045 break;
2046 }
2047 }
2048
2049 if (!found) {
2050 temp_rate_set.rate[temp_rate_set.numRates++] =
2051 ext_rate_set->rate[i];
2052 if (temp_rate_set.numRates >= 12)
2053 break;
2054 }
2055 }
2056 } else if (ext_rate_set->numRates &&
2057 ((temp_rate_set.numRates + ext_rate_set->numRates) <= 12)) {
2058 for (j = 0; ((j < ext_rate_set->numRates) &&
2059 (j < SIR_MAC_RATESET_EID_MAX) &&
2060 ((i + j) < SIR_MAC_RATESET_EID_MAX)); j++)
2061 temp_rate_set.rate[i + j] = ext_rate_set->rate[j];
2062
2063 temp_rate_set.numRates += ext_rate_set->numRates;
2064 } else if (ext_rate_set->numRates) {
2065 lim_log(mac_ctx, LOG2,
2066 "Relying only on the SUPPORTED Rate Set IE...");
2067 }
2068
2069
2070 rates = &sta_ds->supportedRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302071 qdf_mem_set((uint8_t *) rates, sizeof(tSirSupportedRates), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 for (i = 0; (i < temp_rate_set2.numRates &&
2073 i < SIR_MAC_RATESET_EID_MAX); i++) {
2074 for (j = 0; (j < temp_rate_set.numRates &&
2075 j < SIR_MAC_RATESET_EID_MAX); j++) {
2076 if ((temp_rate_set2.rate[i] & 0x7F) !=
2077 (temp_rate_set.rate[j] & 0x7F))
2078 continue;
2079
2080 if (sirIsArate(temp_rate_set2.rate[i] & 0x7f) &&
2081 a_rate_index < SIR_NUM_11A_RATES) {
2082 is_arate = 1;
2083 rates->llaRates[a_rate_index++] =
2084 temp_rate_set2.rate[i];
2085 } else if ((b_rate_index < SIR_NUM_11B_RATES) &&
2086 !(sirIsArate(temp_rate_set2.rate[i] & 0x7f))) {
2087 rates->llbRates[b_rate_index++] =
2088 temp_rate_set2.rate[i];
2089 }
2090 break;
2091 }
2092 }
2093
2094 /*
2095 * Now add the Polaris rates only when Proprietary rates are enabled.
2096 * compute the matching MCS rate set, if peer is 11n capable and self
2097 * mode is 11n
2098 */
2099#ifdef FEATURE_WLAN_TDLS
2100 if (sta_ds->mlmStaContext.htCapability)
2101#else
2102 if (IS_DOT11_MODE_HT(session_entry->dot11mode) &&
2103 (sta_ds->mlmStaContext.htCapability))
2104#endif
2105 {
2106 val = SIZE_OF_SUPPORTED_MCS_SET;
2107 if (wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_MCS_SET,
2108 mcs_set, &val) != eSIR_SUCCESS) {
2109 /* Could not get rateset from CFG. Log error. */
2110 lim_log(mac_ctx, LOGP,
2111 FL("could not retrieve supportedMCSet"));
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08002112 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 }
2114
2115 for (i = 0; i < val; i++)
2116 sta_ds->supportedRates.supportedMCSSet[i] =
2117 mcs_set[i] & supported_mcs_set[i];
2118
2119 lim_log(mac_ctx, LOG2,
2120 FL("lim_populate_matching_rate_set: MCS Rate Set Bitmap"
2121 " from CFG and DPH : "));
2122 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++) {
2123 lim_log(mac_ctx, LOG2, FL("%x %x "), mcs_set[i],
2124 sta_ds->supportedRates.supportedMCSSet[i]);
2125 }
2126 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 lim_populate_vht_mcs_set(mac_ctx, &sta_ds->supportedRates, vht_caps,
2128 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 /*
2130 * Set the erpEnabled bit if the phy is in G mode and at least
2131 * one A rate is supported
2132 */
2133 if ((phy_mode == WNI_CFG_PHY_MODE_11G) && is_arate)
2134 sta_ds->erpEnabled = eHAL_SET;
2135
2136 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137}
2138
2139/**
2140 * lim_populate_vht_caps() - populates vht capabilities based on input
2141 * capabilities
2142 * @input_caps: input capabilities based on which we format the vht
2143 * capabilities
2144 *
2145 * function to populate the supported vht capabilities.
2146 *
2147 * Return: vht capabilities derived based on input parameters.
2148 */
2149static uint32_t lim_populate_vht_caps(tDot11fIEVHTCaps input_caps)
2150{
2151 uint32_t vht_caps;
2152
2153 vht_caps = ((input_caps.maxMPDULen << SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
2154 (input_caps.supportedChannelWidthSet <<
2155 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
2156 (input_caps.ldpcCodingCap <<
2157 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
2158 (input_caps.shortGI80MHz <<
2159 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
2160 (input_caps.shortGI160and80plus80MHz <<
2161 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
2162 (input_caps.txSTBC << SIR_MAC_VHT_CAP_TXSTBC) |
2163 (input_caps.rxSTBC << SIR_MAC_VHT_CAP_RXSTBC) |
2164 (input_caps.suBeamFormerCap <<
2165 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
2166 (input_caps.suBeamformeeCap <<
2167 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
2168 (input_caps.csnofBeamformerAntSup <<
2169 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
2170 (input_caps.numSoundingDim <<
2171 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
2172 (input_caps.muBeamformerCap <<
2173 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
2174 (input_caps.muBeamformeeCap <<
2175 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
2176 (input_caps.vhtTXOPPS <<
2177 SIR_MAC_VHT_CAP_TXOPPS) |
2178 (input_caps.htcVHTCap <<
2179 SIR_MAC_VHT_CAP_HTC_CAP) |
2180 (input_caps.maxAMPDULenExp <<
2181 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
2182 (input_caps.vhtLinkAdaptCap <<
2183 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
2184 (input_caps.rxAntPattern <<
2185 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
2186 (input_caps.txAntPattern <<
2187 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
2188 (input_caps.reserved1 <<
2189 SIR_MAC_VHT_CAP_RESERVED2));
2190
2191 return vht_caps;
2192}
2193/**
2194 * lim_add_sta()- called to add an STA context at hardware
2195 * @mac_ctx: pointer to global mac structure
2196 * @sta_ds: station node
2197 * @update_entry: set to true for updating the entry
2198 * @session_entry: pe session entry
2199 *
2200 * This function is called to add an STA context at hardware
2201 * whenever a STA is (Re) Associated.
2202 *
2203 * Return: eSIR_SUCCESS on success else eSirRetStatus failure codes
2204 */
2205
2206tSirRetStatus
2207lim_add_sta(tpAniSirGlobal mac_ctx,
2208 tpDphHashNode sta_ds, uint8_t update_entry, tpPESession session_entry)
2209{
2210 tpAddStaParams add_sta_params = NULL;
2211 tSirMsgQ msg_q;
2212 tSirRetStatus ret_code = eSIR_SUCCESS;
2213 tSirMacAddr sta_mac, *sta_Addr;
2214 uint8_t i, nw_type_11b = 0;
2215 tpSirAssocReq assoc_req;
2216 tLimIbssPeerNode *peer_node; /* for IBSS mode */
2217 uint8_t *p2p_ie = NULL;
2218
2219 sir_copy_mac_addr(sta_mac, session_entry->selfMacAddr);
2220
2221 lim_log(mac_ctx, LOG1,
2222 FL("sessionid: %d update_entry = %d limsystemrole = %d "),
2223 session_entry->smeSessionId, update_entry,
2224 GET_LIM_SYSTEM_ROLE(session_entry));
2225
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302226 add_sta_params = qdf_mem_malloc(sizeof(tAddStaParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 if (NULL == add_sta_params) {
2228 lim_log(mac_ctx, LOGP,
2229 FL("Unable to allocate memory during ADD_STA"));
2230 return eSIR_MEM_ALLOC_FAILED;
2231 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302232 qdf_mem_set((uint8_t *) add_sta_params, sizeof(tAddStaParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233
2234 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry) ||
2235 LIM_IS_BT_AMP_AP_ROLE(session_entry))
2236 sta_Addr = &sta_ds->staAddr;
2237#ifdef FEATURE_WLAN_TDLS
2238 /* SystemRole shouldn't be matter if staType is TDLS peer */
2239 else if (STA_ENTRY_TDLS_PEER == sta_ds->staType)
2240 sta_Addr = &sta_ds->staAddr;
2241#endif
2242 else
2243 sta_Addr = &sta_mac;
2244
2245 lim_log(mac_ctx, LOG1,
2246 FL(MAC_ADDRESS_STR ": Subtype(Assoc/Reassoc): %d"),
2247 MAC_ADDR_ARRAY(*sta_Addr), sta_ds->mlmStaContext.subType);
2248
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302249 qdf_mem_copy((uint8_t *) add_sta_params->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 (uint8_t *) *sta_Addr, sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302251 qdf_mem_copy((uint8_t *) add_sta_params->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252 session_entry->bssId, sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 qdf_mem_copy(&add_sta_params->capab_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 &sta_ds->mlmStaContext.capabilityInfo,
2255 sizeof(add_sta_params->capab_info));
2256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 /* Copy legacy rates */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302258 qdf_mem_copy((uint8_t *) &add_sta_params->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 (uint8_t *) &sta_ds->supportedRates,
2260 sizeof(tSirSupportedRates));
2261
2262 add_sta_params->assocId = sta_ds->assocId;
2263
2264 add_sta_params->wmmEnabled = sta_ds->qosMode;
2265 add_sta_params->listenInterval = sta_ds->mlmStaContext.listenInterval;
2266 add_sta_params->shortPreambleSupported = sta_ds->shortPreambleEnabled;
2267 if (LIM_IS_AP_ROLE(session_entry) &&
2268 (sta_ds->mlmStaContext.subType == LIM_REASSOC)) {
2269 /*
2270 * TBD - need to remove this REASSOC check
2271 * after fixinf rmmod issue
2272 */
2273 add_sta_params->updateSta = sta_ds->mlmStaContext.updateContext;
2274 }
2275 sta_ds->valid = 0;
2276 sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2277
2278 lim_log(mac_ctx, LOG2,
2279 FL(" Assoc ID: %d wmmEnabled = %d listenInterval = %d"
2280 " shortPreambleSupported: %d "), add_sta_params->assocId,
2281 add_sta_params->wmmEnabled, add_sta_params->listenInterval,
2282 add_sta_params->shortPreambleSupported);
2283 /* This will indicate HAL to "allocate" a new STA index */
2284#ifdef FEATURE_WLAN_TDLS
2285 /*
2286 * As there is corner case in-between add_sta and change_sta,if del_sta
2287 * for other staIdx happened, firmware return wrong staIdx
2288 * (recently removed staIdx). Until we get a confirmation from the
2289 * firmware team it is now return correct staIdx for same sta_mac_addr
2290 * for update case, we want to get around it by passing valid staIdx
2291 * given by add_sta time.
2292 */
2293 if ((STA_ENTRY_TDLS_PEER == sta_ds->staType) && (true == update_entry))
2294 add_sta_params->staIdx = sta_ds->staIndex;
2295 else
2296#endif
2297 add_sta_params->staIdx = STA_INVALID_IDX;
2298 add_sta_params->staType = sta_ds->staType;
2299
2300 add_sta_params->updateSta = update_entry;
2301
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302302 add_sta_params->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 add_sta_params->respReqd = 1;
2304 /* Update HT Capability */
2305
2306 if (LIM_IS_AP_ROLE(session_entry) ||
2307 LIM_IS_BT_AMP_AP_ROLE(session_entry) ||
2308 LIM_IS_IBSS_ROLE(session_entry)) {
2309 add_sta_params->htCapable = sta_ds->mlmStaContext.htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 add_sta_params->vhtCapable =
2311 sta_ds->mlmStaContext.vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 }
2313#ifdef FEATURE_WLAN_TDLS
2314 /* SystemRole shouldn't be matter if staType is TDLS peer */
2315 else if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
2316 add_sta_params->htCapable = sta_ds->mlmStaContext.htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 add_sta_params->vhtCapable =
2318 sta_ds->mlmStaContext.vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 }
2320#endif
2321 else {
2322 add_sta_params->htCapable = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 add_sta_params->vhtCapable = session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324
2325 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 lim_log(mac_ctx, LOG2, FL("vhtCapable: %d "),
2327 add_sta_params->vhtCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 lim_log(mac_ctx, LOG2, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
2329 add_sta_params->staIdx, add_sta_params->updateSta,
2330 add_sta_params->htCapable);
2331
2332 add_sta_params->greenFieldCapable = sta_ds->htGreenfield;
2333 add_sta_params->maxAmpduDensity = sta_ds->htAMpduDensity;
2334 add_sta_params->maxAmpduSize = sta_ds->htMaxRxAMpduFactor;
2335 add_sta_params->fDsssCckMode40Mhz = sta_ds->htDsssCckRate40MHzSupport;
2336 add_sta_params->fShortGI20Mhz = sta_ds->htShortGI20Mhz;
2337 add_sta_params->fShortGI40Mhz = sta_ds->htShortGI40Mhz;
2338 add_sta_params->lsigTxopProtection = sta_ds->htLsigTXOPProtection;
2339 add_sta_params->maxAmsduSize = sta_ds->htMaxAmsduLength;
2340 add_sta_params->ch_width = sta_ds->htSupportedChannelWidthSet;
2341 add_sta_params->mimoPS = sta_ds->htMIMOPSState;
2342
2343 lim_log(mac_ctx, LOG2,
2344 FL("greenFieldCapable: %d maxAmpduDensity = %d maxAmpduDensity = %d"),
2345 add_sta_params->greenFieldCapable,
2346 add_sta_params->maxAmpduDensity, add_sta_params->maxAmpduSize);
2347
2348 lim_log(mac_ctx, LOG2,
2349 FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d fShortGI40Mhz: %d"),
2350 add_sta_params->fDsssCckMode40Mhz,
2351 add_sta_params->fShortGI20Mhz, add_sta_params->fShortGI40Mhz);
2352
2353 lim_log(mac_ctx, LOG2,
2354 FL("lsigTxopProtection: %d maxAmsduSize: %d txChannelWidth: %d mimoPS: %d "),
2355 add_sta_params->lsigTxopProtection,
2356 add_sta_params->maxAmsduSize, add_sta_params->ch_width,
2357 add_sta_params->mimoPS);
2358
2359 if (add_sta_params->vhtCapable) {
2360 if (sta_ds->vhtSupportedChannelWidthSet)
2361 add_sta_params->ch_width =
2362 sta_ds->vhtSupportedChannelWidthSet + 1;
2363
2364 add_sta_params->vhtSupportedRxNss = sta_ds->vhtSupportedRxNss;
2365 add_sta_params->vhtTxBFCapable =
2366#ifdef FEATURE_WLAN_TDLS
2367 ((STA_ENTRY_PEER == sta_ds->staType)
2368 || (STA_ENTRY_TDLS_PEER == sta_ds->staType)) ?
2369 sta_ds->vhtBeamFormerCapable :
2370 session_entry->txBFIniFeatureEnabled;
2371#else
2372 (STA_ENTRY_PEER == sta_ds->staType) ?
2373 sta_ds->vhtBeamFormerCapable :
2374 session_entry->txBFIniFeatureEnabled;
2375#endif
2376 add_sta_params->enable_su_tx_bformer =
2377 sta_ds->vht_su_bfee_capable;
2378 }
2379
2380 lim_log(mac_ctx, LOGE, FL("TxChWidth %d vhtTxBFCap %d, su_bfer %d"),
2381 add_sta_params->ch_width, add_sta_params->vhtTxBFCapable,
2382 add_sta_params->enable_su_tx_bformer);
2383#ifdef FEATURE_WLAN_TDLS
2384 if ((STA_ENTRY_PEER == sta_ds->staType) ||
2385 (STA_ENTRY_TDLS_PEER == sta_ds->staType))
2386#else
2387 if (STA_ENTRY_PEER == sta_ds->staType)
2388#endif
2389 {
2390 /*
2391 * peer STA get the LDPC capability from sta_ds,
2392 * which populated from
2393 * HT/VHT capability
2394 */
2395 if (add_sta_params->vhtTxBFCapable
2396 && mac_ctx->lim.disableLDPCWithTxbfAP) {
2397 add_sta_params->htLdpcCapable = 0;
2398 add_sta_params->vhtLdpcCapable = 0;
2399 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08002400 if (session_entry->txLdpcIniFeatureEnabled & 0x1)
2401 add_sta_params->htLdpcCapable =
2402 sta_ds->htLdpcCapable;
2403 else
2404 add_sta_params->htLdpcCapable = 0;
2405
2406 if (session_entry->txLdpcIniFeatureEnabled & 0x2)
2407 add_sta_params->vhtLdpcCapable =
2408 sta_ds->vhtLdpcCapable;
2409 else
2410 add_sta_params->vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 }
2412 } else if (STA_ENTRY_SELF == sta_ds->staType) {
2413 /* For Self STA get the LDPC capability from config.ini */
2414 add_sta_params->htLdpcCapable =
2415 (session_entry->txLdpcIniFeatureEnabled & 0x01);
2416 add_sta_params->vhtLdpcCapable =
2417 ((session_entry->txLdpcIniFeatureEnabled >> 1) & 0x01);
2418 }
2419
2420 /* Update PE session ID */
2421 add_sta_params->sessionId = session_entry->peSessionId;
2422
2423 /* Update SME session ID */
2424 add_sta_params->smesessionId = session_entry->smeSessionId;
2425
2426 add_sta_params->maxTxPower = session_entry->maxTxPower;
2427
2428 if (session_entry->parsedAssocReq != NULL) {
2429 uint16_t aid = sta_ds->assocId;
2430 /* Get a copy of the already parsed Assoc Request */
2431 assoc_req =
2432 (tpSirAssocReq) session_entry->parsedAssocReq[aid];
2433 if (assoc_req && assoc_req->addIEPresent
2434 && assoc_req->addIE.length) {
2435 p2p_ie = limGetP2pIEPtr(mac_ctx,
2436 assoc_req->addIE.addIEdata,
2437 assoc_req->addIE.length);
2438 }
2439
2440 add_sta_params->p2pCapableSta = (p2p_ie != NULL);
2441 if (assoc_req && add_sta_params->htCapable) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302442 qdf_mem_copy(&add_sta_params->ht_caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 ((uint8_t *) &assoc_req->HTCaps) + 1,
2444 sizeof(add_sta_params->ht_caps));
2445 }
2446
2447 if (assoc_req && add_sta_params->vhtCapable)
2448 add_sta_params->vht_caps =
2449 lim_populate_vht_caps(assoc_req->VHTCaps);
2450 } else if (LIM_IS_IBSS_ROLE(session_entry)) {
2451
2452 /*
2453 * in IBSS mode, use peer node as the source of ht_caps
2454 * and vht_caps
2455 */
2456 peer_node = lim_ibss_peer_find(mac_ctx, *sta_Addr);
2457 if (!peer_node) {
2458 lim_log(mac_ctx, LOGP,
2459 FL("Can't find IBSS peer node for ADD_STA"));
2460 return eSIR_HAL_STA_DOES_NOT_EXIST;
2461 }
2462
2463 if (peer_node->atimIePresent) {
2464 add_sta_params->atimIePresent =
2465 peer_node->atimIePresent;
2466 add_sta_params->peerAtimWindowLength =
2467 peer_node->peerAtimWindowLength;
2468 }
2469
2470 add_sta_params->ht_caps =
2471 (peer_node->htSupportedChannelWidthSet <<
2472 SIR_MAC_HT_CAP_CHWIDTH40_S) |
2473 (peer_node->htGreenfield <<
2474 SIR_MAC_HT_CAP_GREENFIELD_S) |
2475 (peer_node->htShortGI20Mhz <<
2476 SIR_MAC_HT_CAP_SHORTGI20MHZ_S) |
2477 (peer_node->htShortGI40Mhz <<
2478 SIR_MAC_HT_CAP_SHORTGI40MHZ_S) |
2479 (SIR_MAC_TXSTBC <<
2480 SIR_MAC_HT_CAP_TXSTBC_S) |
2481 (SIR_MAC_RXSTBC <<
2482 SIR_MAC_HT_CAP_RXSTBC_S) |
2483 (peer_node->htMaxAmsduLength <<
2484 SIR_MAC_HT_CAP_MAXAMSDUSIZE_S) |
2485 (peer_node->htDsssCckRate40MHzSupport <<
2486 SIR_MAC_HT_CAP_DSSSCCK40_S);
2487
2488 add_sta_params->vht_caps =
2489 lim_populate_vht_caps(peer_node->VHTCaps);
2490 }
2491#ifdef FEATURE_WLAN_TDLS
2492 if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
2493 add_sta_params->ht_caps = sta_ds->ht_caps;
2494 add_sta_params->vht_caps = sta_ds->vht_caps;
2495
2496 lim_log(mac_ctx, LOG1,
2497 FL("Sta type is TDLS_PEER, ht_caps: 0x%x, vht_caps: 0x%x"),
2498 add_sta_params->ht_caps,
2499 add_sta_params->vht_caps);
2500 }
2501#endif
2502
2503#ifdef FEATURE_WLAN_TDLS
2504 if (sta_ds->wmeEnabled &&
2505 (LIM_IS_AP_ROLE(session_entry) ||
2506 (STA_ENTRY_TDLS_PEER == sta_ds->staType)))
2507#else
2508 if (sta_ds->wmeEnabled && LIM_IS_AP_ROLE(session_entry))
2509#endif
2510 {
2511 add_sta_params->uAPSD = 0;
2512 /*
2513 * update UAPSD and send it to LIM to add STA
2514 * bitmap MSB <- LSB MSB 4 bits are for
2515 * trigger enabled AC setting and LSB 4 bits
2516 * are for delivery enabled AC setting
2517 * 7 6 5 4 3 2 1 0
2518 * BE BK VI VO BE BK VI VO
2519 */
2520 add_sta_params->uAPSD |=
2521 sta_ds->qos.capability.qosInfo.acvo_uapsd;
2522 add_sta_params->uAPSD |=
2523 (sta_ds->qos.capability.qosInfo.acvi_uapsd << 1);
2524 add_sta_params->uAPSD |=
2525 (sta_ds->qos.capability.qosInfo.acbk_uapsd << 2);
2526 add_sta_params->uAPSD |=
2527 (sta_ds->qos.capability.qosInfo.acbe_uapsd << 3);
2528 /*
2529 * making delivery enabled and
2530 * trigger enabled setting the same.
2531 */
2532 add_sta_params->uAPSD |= add_sta_params->uAPSD << 4;
2533
2534 add_sta_params->maxSPLen =
2535 sta_ds->qos.capability.qosInfo.maxSpLen;
2536 lim_log(mac_ctx, LOG1, FL("uAPSD = 0x%x, maxSpLen = %d"),
2537 add_sta_params->uAPSD, add_sta_params->maxSPLen);
2538 }
2539#ifdef WLAN_FEATURE_11W
2540 add_sta_params->rmfEnabled = sta_ds->rmfEnabled;
2541 lim_log(mac_ctx, LOG1, FL("PMF enabled %d"),
2542 add_sta_params->rmfEnabled);
2543#endif
2544
2545 lim_log(mac_ctx, LOG2, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
2546 "p2pCapableSta: %d"),
2547 add_sta_params->htLdpcCapable, add_sta_params->vhtLdpcCapable,
2548 add_sta_params->p2pCapableSta);
2549
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08002550 if (!add_sta_params->htLdpcCapable)
2551 add_sta_params->ht_caps &= ~(1 << SIR_MAC_HT_CAP_ADVCODING_S);
2552 if (!add_sta_params->vhtLdpcCapable)
2553 add_sta_params->vht_caps &=
2554 ~(1 << SIR_MAC_VHT_CAP_LDPC_CODING_CAP);
2555
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 /*
2557 * we need to defer the message until we get the
2558 * response back from HAL.
2559 */
2560 if (add_sta_params->respReqd)
2561 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, false);
2562
2563 for (i = 0; i < SIR_NUM_11A_RATES; i++) {
2564 if (sirIsArate(sta_ds->supportedRates.llaRates[i] & 0x7F)) {
2565 nw_type_11b = 0;
2566 break;
2567 } else {
2568 nw_type_11b = 1;
2569 }
2570 }
2571 if (nw_type_11b)
2572 add_sta_params->nwType = eSIR_11B_NW_TYPE;
2573 else
2574 add_sta_params->nwType = session_entry->nwType;
2575
2576 msg_q.type = WMA_ADD_STA_REQ;
2577
2578 msg_q.reserved = 0;
2579 msg_q.bodyptr = add_sta_params;
2580 msg_q.bodyval = 0;
2581
2582 lim_log(mac_ctx, LOG1, FL("Sending WMA_ADD_STA_REQ for assocId %d"),
2583 sta_ds->assocId);
2584 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId,
2585 msg_q.type));
2586
2587 ret_code = wma_post_ctrl_msg(mac_ctx, &msg_q);
2588 if (eSIR_SUCCESS != ret_code) {
2589 if (add_sta_params->respReqd)
2590 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
2591 lim_log(mac_ctx, LOGE,
2592 FL("ADD_STA_REQ for aId %d failed (reason %X)"),
2593 sta_ds->assocId, ret_code);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302594 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 }
2596
2597 return ret_code;
2598}
2599
2600/**
2601 * lim_del_sta()
2602 *
2603 ***FUNCTION:
2604 * This function is called to delete an STA context at hardware
2605 * whenever a STA is disassociated
2606 *
2607 ***LOGIC:
2608 *
2609 ***ASSUMPTIONS:
2610 * NA
2611 *
2612 ***NOTE:
2613 * NA
2614 *
2615 * @param pMac - Pointer to Global MAC structure
2616 * @param pStaDs - Pointer to the STA datastructure created by
2617 * LIM and maintained by DPH
2618 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2619 * or not (false)
2620 * @return retCode - Indicates success or failure return code
2621 */
2622
2623tSirRetStatus
2624lim_del_sta(tpAniSirGlobal pMac,
2625 tpDphHashNode pStaDs, bool fRespReqd, tpPESession psessionEntry)
2626{
2627 tpDeleteStaParams pDelStaParams = NULL;
2628 tSirMsgQ msgQ;
2629 tSirRetStatus retCode = eSIR_SUCCESS;
2630
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302631 pDelStaParams = qdf_mem_malloc(sizeof(tDeleteStaParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 if (NULL == pDelStaParams) {
2633 lim_log(pMac, LOGP,
2634 FL("Unable to allocate memory during ADD_STA"));
2635 return eSIR_MEM_ALLOC_FAILED;
2636 }
2637
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302638 qdf_mem_set((uint8_t *) pDelStaParams, sizeof(tDeleteStaParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639
2640 /* */
2641 /* DPH contains the STA index only for "peer" STA entries. */
2642 /* LIM global contains "self" STA index */
2643 /* Thus, */
2644 /* if( STA role ) */
2645 /* get STA index from LIM global */
2646 /* else */
2647 /* get STA index from DPH */
2648 /* */
2649
2650#ifdef FEATURE_WLAN_TDLS
2651 if ((LIM_IS_STA_ROLE(psessionEntry) &&
2652 (pStaDs->staType != STA_ENTRY_TDLS_PEER)) ||
2653 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
2654#else
2655 if (LIM_IS_STA_ROLE(psessionEntry) ||
2656 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
2657#endif
2658 pDelStaParams->staIdx = psessionEntry->staId;
2659
2660 else
2661 pDelStaParams->staIdx = pStaDs->staIndex;
2662
2663 pDelStaParams->assocId = pStaDs->assocId;
2664 pStaDs->valid = 0;
2665
2666 if (!fRespReqd)
2667 pDelStaParams->respReqd = 0;
2668 else {
2669 /* when lim_del_sta is called from processSmeAssocCnf then mlmState is already set properly. */
2670 if (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
2671 GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs)) {
2672 MTRACE(mac_trace
2673 (pMac, TRACE_CODE_MLM_STATE,
2674 psessionEntry->peSessionId,
2675 eLIM_MLM_WT_DEL_STA_RSP_STATE));
2676 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs,
2677 eLIM_MLM_WT_DEL_STA_RSP_STATE);
2678 }
2679 if (LIM_IS_STA_ROLE(psessionEntry) ||
2680 LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
2681 MTRACE(mac_trace
2682 (pMac, TRACE_CODE_MLM_STATE,
2683 psessionEntry->peSessionId,
2684 eLIM_MLM_WT_DEL_STA_RSP_STATE));
2685
2686 psessionEntry->limMlmState =
2687 eLIM_MLM_WT_DEL_STA_RSP_STATE;
2688
2689 }
2690 pDelStaParams->respReqd = 1;
2691 /* we need to defer the message until we get the response back from HAL. */
2692 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2693 }
2694
2695 /* Update PE session ID */
2696 pDelStaParams->sessionId = psessionEntry->peSessionId;
2697 pDelStaParams->smesessionId = psessionEntry->smeSessionId;
2698
2699 pDelStaParams->staType = pStaDs->staType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302700 qdf_mem_copy((uint8_t *) pDelStaParams->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 (uint8_t *) pStaDs->staAddr, sizeof(tSirMacAddr));
2702
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302703 pDelStaParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 msgQ.type = WMA_DELETE_STA_REQ;
2705 msgQ.reserved = 0;
2706 msgQ.bodyptr = pDelStaParams;
2707 msgQ.bodyval = 0;
2708
2709 lim_log(pMac, LOG1, FL("Sessionid %d :Sending SIR_HAL_DELETE_STA_REQ "
2710 "for STAID: %X and AssocID: %d MAC : "
2711 MAC_ADDRESS_STR), pDelStaParams->sessionId,
2712 pDelStaParams->staIdx, pDelStaParams->assocId,
2713 MAC_ADDR_ARRAY(pStaDs->staAddr));
2714
2715 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
2716 retCode = wma_post_ctrl_msg(pMac, &msgQ);
2717 if (eSIR_SUCCESS != retCode) {
2718 if (fRespReqd)
2719 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
2720 lim_log(pMac, LOGE,
2721 FL("Posting DELETE_STA_REQ to HAL failed, reason=%X"),
2722 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302723 qdf_mem_free(pDelStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 }
2725
2726 return retCode;
2727}
2728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729/**
2730 * lim_add_ft_sta_self()- function to add STA once we have connected with a
2731 * new AP
2732 * @mac_ctx: pointer to global mac structure
2733 * @assoc_id: association id for the station connection
2734 * @session_entry: pe session entr
2735 *
2736 * This function is called to add a STA once we have connected with a new
2737 * AP, that we have performed an FT to.
2738 *
2739 * The Add STA Response is created and now after the ADD Bss Is Successful
2740 * we add the self sta. We update with the association id from the reassoc
2741 * response from the AP.
2742 *
2743 * Return: eSIR_SUCCESS on success else eSirRetStatus failure codes
2744 */
2745tSirRetStatus lim_add_ft_sta_self(tpAniSirGlobal mac_ctx, uint16_t assoc_id,
2746 tpPESession session_entry)
2747{
2748 tpAddStaParams add_sta_params = NULL;
2749 tSirRetStatus ret_code = eSIR_SUCCESS;
2750 tSirMsgQ msg_q;
2751
2752 add_sta_params = session_entry->ftPEContext.pAddStaReq;
2753 add_sta_params->assocId = assoc_id;
2754 add_sta_params->smesessionId = session_entry->smeSessionId;
2755
2756 msg_q.type = WMA_ADD_STA_REQ;
2757 msg_q.reserved = 0;
2758 msg_q.bodyptr = add_sta_params;
2759 msg_q.bodyval = 0;
2760
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302761 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 "Sending WMA_ADD_STA_REQ (aid %d)",
2763 add_sta_params->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId,
2765 msg_q.type));
2766
2767 session_entry->limPrevMlmState = session_entry->limMlmState;
2768 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
2769 session_entry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
2770 session_entry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2771 ret_code = wma_post_ctrl_msg(mac_ctx, &msg_q);
2772 if (eSIR_SUCCESS != ret_code) {
2773 lim_log(mac_ctx, LOGE,
2774 FL("Posting WMA_ADD_STA_REQ to HAL failed, reason=%X"),
2775 ret_code);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302776 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777 }
2778
2779 session_entry->ftPEContext.pAddStaReq = NULL;
2780 return ret_code;
2781}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782
2783/**
2784 * lim_add_sta_self()
2785 *
2786 ***FUNCTION:
2787 * This function is called to add an STA context at hardware
2788 * whenever a STA is (Re) Associated.
2789 *
2790 ***LOGIC:
2791 *
2792 ***ASSUMPTIONS:
2793 * NA
2794 *
2795 ***NOTE:
2796 * NA
2797 *
2798 * @param pMac - Pointer to Global MAC structure
2799 * @param pStaDs - Pointer to the STA datastructure created by
2800 * LIM and maintained by DPH
2801 * @return retCode - Indicates success or failure return code
2802 */
2803
2804tSirRetStatus
2805lim_add_sta_self(tpAniSirGlobal pMac, uint16_t staIdx, uint8_t updateSta,
2806 tpPESession psessionEntry)
2807{
2808 tpAddStaParams pAddStaParams = NULL;
2809 tSirMsgQ msgQ;
2810 tSirRetStatus retCode = eSIR_SUCCESS;
2811 tSirMacAddr staMac;
2812 uint32_t listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
2813 uint32_t shortGi20MhzSupport;
2814 uint32_t shortGi40MhzSupport;
2815 uint32_t ampduLenExponent = 0;
2816 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2817 * that cfg carries the systemwide capability that device under
2818 * consideration can support. This capability gets plumbed into the cfg
2819 * cache at system initialization time via the .dat and .ini file override
2820 * mechanisms and will not change. If it does change, it is the
2821 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2822 * command.*/
2823 uint32_t selfStaDot11Mode = 0, selfTxWidth = 0;
2824 uint32_t val;
2825 wlan_cfg_get_int(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
2826 lim_log(pMac, LOG1, FL("cfgDot11Mode %d"), (int)selfStaDot11Mode);
2827 wlan_cfg_get_int(pMac, WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,
2828 &selfTxWidth);
2829 lim_log(pMac, LOG1, FL("SGI 20 %d"), (int)selfTxWidth);
2830 lim_log(pMac, LOG1, FL("Roam Channel Bonding Mode %d"),
2831 (int)pMac->roam.configParam.uCfgDot11Mode);
2832
2833 sir_copy_mac_addr(staMac, psessionEntry->selfMacAddr);
2834 lim_log(pMac, LOG1, FL(MAC_ADDRESS_STR ": "), MAC_ADDR_ARRAY(staMac));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302835 pAddStaParams = qdf_mem_malloc(sizeof(tAddStaParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 if (NULL == pAddStaParams) {
2837 lim_log(pMac, LOGP,
2838 FL("Unable to allocate memory during ADD_STA"));
2839 return eSIR_MEM_ALLOC_FAILED;
2840 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302841 qdf_mem_set((uint8_t *) pAddStaParams, sizeof(tAddStaParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842
2843 /* / Add STA context at MAC HW (BMU, RHP & TFP) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302844 qdf_mem_copy((uint8_t *) pAddStaParams->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 (uint8_t *) staMac, sizeof(tSirMacAddr));
2846
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302847 qdf_mem_copy((uint8_t *) pAddStaParams->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 psessionEntry->bssId, sizeof(tSirMacAddr));
2849
2850 pAddStaParams->assocId = psessionEntry->limAID;
2851 pAddStaParams->staType = STA_ENTRY_SELF;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302852 pAddStaParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 pAddStaParams->respReqd = 1;
2854
2855 /* Update PE session ID */
2856 pAddStaParams->sessionId = psessionEntry->peSessionId;
2857
2858 /* Update SME session ID */
2859 pAddStaParams->smesessionId = psessionEntry->smeSessionId;
2860
2861 pAddStaParams->maxTxPower = psessionEntry->maxTxPower;
2862
2863 /* This will indicate HAL to "allocate" a new STA index */
2864 pAddStaParams->staIdx = staIdx;
2865 pAddStaParams->updateSta = updateSta;
2866
2867 if (wlan_cfg_get_int(pMac, WNI_CFG_SHORT_PREAMBLE, &val) !=
2868 eSIR_SUCCESS) {
2869 lim_log(pMac, LOGE, FL(
2870 "Couldn't get SHORT_PREAMBLE, set default"));
2871 pAddStaParams->shortPreambleSupported = 1;
2872 } else {
2873 pAddStaParams->shortPreambleSupported = val;
2874 }
2875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 lim_populate_own_rate_set(pMac, &pAddStaParams->supportedRates, NULL, false,
2877 psessionEntry, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 if (IS_DOT11_MODE_HT(selfStaDot11Mode)) {
2879 pAddStaParams->htCapable = true;
2880#ifdef DISABLE_GF_FOR_INTEROP
2881 if ((psessionEntry->pLimJoinReq != NULL)
2882 && (!psessionEntry->pLimJoinReq->bssDescription.
2883 aniIndicator)) {
2884 lim_log(pMac, LOGE,
2885 FL
2886 (" Turning off Greenfield, when adding self entry"));
2887 pAddStaParams->greenFieldCapable =
2888 WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2889 } else
2890#endif
2891 {
2892 pAddStaParams->greenFieldCapable =
2893 lim_get_ht_capability(pMac, eHT_GREENFIELD,
2894 psessionEntry);
2895 pAddStaParams->ch_width =
2896 pMac->roam.configParam.channelBondingMode5GHz;
2897 pAddStaParams->mimoPS =
2898 lim_get_ht_capability(pMac, eHT_MIMO_POWER_SAVE,
2899 psessionEntry);
2900 pAddStaParams->rifsMode =
2901 lim_get_ht_capability(pMac, eHT_RIFS_MODE,
2902 psessionEntry);
2903 pAddStaParams->lsigTxopProtection =
2904 lim_get_ht_capability(pMac, eHT_LSIG_TXOP_PROTECTION,
2905 psessionEntry);
2906 pAddStaParams->maxAmpduDensity =
2907 lim_get_ht_capability(pMac, eHT_MPDU_DENSITY,
2908 psessionEntry);
2909 pAddStaParams->maxAmpduSize =
2910 lim_get_ht_capability(pMac, eHT_MAX_RX_AMPDU_FACTOR,
2911 psessionEntry);
2912 pAddStaParams->maxAmsduSize =
2913 lim_get_ht_capability(pMac, eHT_MAX_AMSDU_LENGTH,
2914 psessionEntry);
2915 pAddStaParams->fDsssCckMode40Mhz =
2916 lim_get_ht_capability(pMac, eHT_DSSS_CCK_MODE_40MHZ,
2917 psessionEntry);
2918 /*
2919 * We will read the gShortGI20Mhz from ini file, and if it is set
2920 * to 1 then we will tell Peer that we support 40Mhz short GI
2921 */
2922 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int
2923 (pMac, WNI_CFG_SHORT_GI_20MHZ,
2924 &shortGi20MhzSupport))) {
2925 if (true == shortGi20MhzSupport) {
2926 pAddStaParams->fShortGI20Mhz =
2927 WNI_CFG_SHORT_GI_20MHZ_STAMAX;
2928 } else {
2929 pAddStaParams->fShortGI20Mhz = false;
2930 }
2931 } else {
2932 PELOGE(lim_log
2933 (pMac, LOGE,
2934 FL("could not retrieve shortGI 20Mhz"
2935 "CFG,setting value to default"));
2936 )
2937 pAddStaParams->fShortGI20Mhz =
2938 WNI_CFG_SHORT_GI_20MHZ_STADEF;
2939 }
2940
2941 /*
2942 * We will read the gShortGI40Mhz from ini file, and if it is set
2943 * to 1 then we will tell Peer that we support 40Mhz short GI
2944 */
2945 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int
2946 (pMac, WNI_CFG_SHORT_GI_40MHZ,
2947 &shortGi40MhzSupport))) {
2948 if (true == shortGi40MhzSupport) {
2949 pAddStaParams->fShortGI40Mhz =
2950 WNI_CFG_SHORT_GI_40MHZ_STAMAX;
2951 } else {
2952 pAddStaParams->fShortGI40Mhz = false;
2953 }
2954 } else {
2955 PELOGE(lim_log
2956 (pMac, LOGE,
2957 FL("could not retrieve shortGI 40Mhz"
2958 "CFG,setting value to default"));
2959 )
2960 pAddStaParams->fShortGI40Mhz =
2961 WNI_CFG_SHORT_GI_40MHZ_STADEF;
2962 }
2963 lim_log(pMac, LOG2,
2964 FL(" greenFieldCapable: %d maxAmpduDensity = %d "
2965 "maxAmpduSize = %d"),
2966 pAddStaParams->greenFieldCapable,
2967 pAddStaParams->maxAmpduDensity,
2968 pAddStaParams->maxAmpduSize);
2969
2970 lim_log(pMac, LOG2,
2971 FL("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
2972 "fShortGI40Mhz: %d lsigTxopProtection: %d"),
2973 pAddStaParams->fDsssCckMode40Mhz,
2974 pAddStaParams->fShortGI20Mhz,
2975 pAddStaParams->fShortGI40Mhz,
2976 pAddStaParams->lsigTxopProtection);
2977
2978 lim_log(pMac, LOG2,
2979 FL("maxAmsduSize: %d txChannelWidth: %d mimoPS: %d rifsMode %d"),
2980 pAddStaParams->maxAmsduSize,
2981 pAddStaParams->ch_width,
2982 pAddStaParams->mimoPS, pAddStaParams->rifsMode);
2983 }
2984 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
2986 if (pAddStaParams->vhtCapable) {
2987 pAddStaParams->ch_width =
2988 psessionEntry->ch_width;
2989 lim_log(pMac, LOG1, FL("VHT WIDTH SET %d"),
2990 pAddStaParams->ch_width);
2991 }
2992 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
2993 pAddStaParams->enable_su_tx_bformer =
2994 psessionEntry->enable_su_tx_bformer;
2995 lim_log(pMac, LOG2, FL("vhtCapable: %d vhtTxBFCapable %d, su_bfer %d"),
2996 pAddStaParams->vhtCapable, pAddStaParams->vhtTxBFCapable,
2997 pAddStaParams->enable_su_tx_bformer);
2998
2999 /* In 11ac mode, the hardware is capable of supporting 128K AMPDU size */
3000 if (IS_DOT11_MODE_VHT(selfStaDot11Mode)) {
3001 if (wlan_cfg_get_int
3002 (pMac, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &ampduLenExponent)
3003 != eSIR_SUCCESS) {
3004 lim_log(pMac, LOGP,
3005 FL
3006 ("Couldn't get WNI_CFG_VHT_AMPDU_LEN_EXPONENT"));
3007 }
3008 pAddStaParams->maxAmpduSize = (uint8_t) ampduLenExponent;
3009 }
3010 pAddStaParams->vhtTxMUBformeeCapable = psessionEntry->txMuBformee;
3011 pAddStaParams->enableVhtpAid = psessionEntry->enableVhtpAid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 pAddStaParams->enableAmpduPs = psessionEntry->enableAmpduPs;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08003013 pAddStaParams->enableHtSmps = (psessionEntry->enableHtSmps &&
3014 (!psessionEntry->supported_nss_1x1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 pAddStaParams->htSmpsconfig = psessionEntry->htSmpsvalue;
3016
3017 /* For Self STA get the LDPC capability from session i.e config.ini */
3018 pAddStaParams->htLdpcCapable =
3019 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
3020 pAddStaParams->vhtLdpcCapable =
3021 ((psessionEntry->txLdpcIniFeatureEnabled >> 1) & 0x01);
3022
3023 if (wlan_cfg_get_int(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) !=
3024 eSIR_SUCCESS)
3025 lim_log(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
3026 pAddStaParams->listenInterval = (uint16_t) listenInterval;
3027
Anurag Chouhan6d760662016-02-20 16:05:43 +05303028 if (QDF_P2P_CLIENT_MODE == psessionEntry->pePersona) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 pAddStaParams->p2pCapableSta = 1;
3030 }
3031
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 lim_log(pMac, LOG2, FL(" StaIdx: %d updateSta = %d htcapable = %d "),
3033 pAddStaParams->staIdx, pAddStaParams->updateSta,
3034 pAddStaParams->htCapable);
3035
3036 lim_log(pMac, LOG2, FL("htLdpcCapable: %d vhtLdpcCapable: %d "
3037 "p2pCapableSta: %d"),
3038 pAddStaParams->htLdpcCapable, pAddStaParams->vhtLdpcCapable,
3039 pAddStaParams->p2pCapableSta);
3040
3041 if (psessionEntry->isNonRoamReassoc) {
3042 pAddStaParams->nonRoamReassoc = 1;
3043 psessionEntry->isNonRoamReassoc = 0;
3044 }
3045 lim_log(pMac, LOG2, FL("sessionid: %d Assoc ID: %d listenInterval = %d "
3046 "shortPreambleSupported: %d"),
3047 psessionEntry->smeSessionId, pAddStaParams->assocId,
3048 pAddStaParams->listenInterval,
3049 pAddStaParams->shortPreambleSupported);
3050
3051 msgQ.type = WMA_ADD_STA_REQ;
3052 msgQ.reserved = 0;
3053 msgQ.bodyptr = pAddStaParams;
3054 msgQ.bodyval = 0;
3055
3056 lim_log(pMac, LOG1, FL(MAC_ADDRESS_STR ":Sessionid %d : "
3057 "Sending WMA_ADD_STA_REQ. (aid %d)"),
3058 MAC_ADDR_ARRAY(pAddStaParams->staMac),
3059 pAddStaParams->sessionId, pAddStaParams->assocId);
3060 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
3061
3062 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3063 if (eSIR_SUCCESS != retCode) {
3064 lim_log(pMac, LOGE,
3065 FL("Posting WMA_ADD_STA_REQ to HAL failed, reason=%X"),
3066 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303067 qdf_mem_free(pAddStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 }
3069 return retCode;
3070}
3071
3072/**
3073 * limTeardownInfraBSS()
3074 *
3075 ***FUNCTION:
3076 * This function is called by various LIM functions to teardown
3077 * an established Infrastructure BSS
3078 *
3079 ***LOGIC:
3080 *
3081 ***ASSUMPTIONS:
3082 *
3083 ***NOTE:
3084 *
3085 * @param pMac - Pointer to Global MAC structure
3086 * @return None
3087 */
3088
3089void lim_teardown_infra_bss(tpAniSirGlobal pMac, tpPESession psessionEntry)
3090{
3091 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3092
3093 /**
3094 * Send Broadcast Disassociate frame with
3095 * 'leaving BSS' reason.
3096 */
3097 lim_send_disassoc_mgmt_frame(pMac,
3098 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
3099 bcAddr, psessionEntry, false);
3100} /*** end lim_teardown_infra_bss() ***/
3101
3102/**
3103 * lim_handle_cnf_wait_timeout()
3104 *
3105 ***FUNCTION:
3106 * This function is called by limProcessMessageQueue to handle
3107 * various confirmation failure cases.
3108 *
3109 ***LOGIC:
3110 *
3111 ***ASSUMPTIONS:
3112 *
3113 ***NOTE:
3114 *
3115 * @param pMac - Pointer to Global MAC structure
3116 * @param pStaDs - Pointer to a sta descriptor
3117 * @return None
3118 */
3119
3120void lim_handle_cnf_wait_timeout(tpAniSirGlobal pMac, uint16_t staId)
3121{
3122 tpDphHashNode pStaDs;
3123 tpPESession psessionEntry = NULL;
3124
3125 psessionEntry = pe_find_session_by_session_id(pMac,
3126 pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId);
3127 if (psessionEntry == NULL) {
3128 lim_log(pMac, LOGP,
3129 FL("Session Does not exist for given sessionID"));
3130 return;
3131 }
3132 pStaDs = dph_get_hash_entry(pMac, staId, &psessionEntry->dph.dphHashTable);
3133
3134 if (pStaDs == NULL) {
3135 PELOGW(lim_log
3136 (pMac, LOGW,
3137 FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT."));
3138 )
3139 return;
3140 }
3141
3142 switch (pStaDs->mlmStaContext.mlmState) {
3143 case eLIM_MLM_WT_ASSOC_CNF_STATE:
3144 PELOGW(lim_log
3145 (pMac, LOGW,
3146 FL
3147 ("Did not receive Assoc Cnf in eLIM_MLM_WT_ASSOC_CNF_STATE sta Assoc id %d"),
3148 pStaDs->assocId);
3149 )
3150 lim_print_mac_addr(pMac, pStaDs->staAddr, LOGW);
3151
3152 if (LIM_IS_AP_ROLE(psessionEntry) ||
3153 LIM_IS_BT_AMP_AP_ROLE(psessionEntry)) {
3154 lim_reject_association(pMac, pStaDs->staAddr,
3155 pStaDs->mlmStaContext.subType,
3156 true,
3157 pStaDs->mlmStaContext.authType,
3158 pStaDs->assocId, true,
3159 (tSirResultCodes)
3160 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3161 psessionEntry);
3162 }
3163 break;
3164
3165 default:
3166 lim_log(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d"),
3167 pStaDs->mlmStaContext.mlmState);
3168 }
3169}
3170
3171/**
3172 * lim_delete_dph_hash_entry()- function to delete dph hash entry
3173 * @mac_ctx: pointer to global mac structure
3174 * @sta_addr: peer station address
3175 * @sta_id: id assigned to peer station
3176 * @session_entry: pe session entry
3177 *
3178 * This function is called whenever we need to delete
3179 * the dph hash entry
3180 *
3181 * Return: none
3182 */
3183
3184void
3185lim_delete_dph_hash_entry(tpAniSirGlobal mac_ctx, tSirMacAddr sta_addr,
3186 uint16_t sta_id, tpPESession session_entry)
3187{
3188 uint16_t aid;
3189 tpDphHashNode sta_ds;
3190 tUpdateBeaconParams beacon_params;
3191
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303192 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 beacon_params.paramChangeBitmap = 0;
3194 lim_deactivate_and_change_per_sta_id_timer(mac_ctx, eLIM_CNF_WAIT_TIMER,
3195 sta_id);
3196 if (NULL == session_entry) {
3197 lim_log(mac_ctx, LOGE, FL("NULL session_entry"));
3198 return;
3199 }
3200
3201 beacon_params.bssIdx = session_entry->bssIdx;
3202 sta_ds = dph_lookup_hash_entry(mac_ctx, sta_addr, &aid,
3203 &session_entry->dph.dphHashTable);
3204
3205 if (sta_ds == NULL) {
3206 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
3207 return;
3208 }
3209
3210 lim_log(mac_ctx, LOGW, FL("Deleting DPH Hash entry for STAID: %X"),
3211 sta_id);
3212 /*
3213 * update the station count and perform associated actions
3214 * do this before deleting the dph hash entry
3215 */
3216 lim_util_count_sta_del(mac_ctx, sta_ds, session_entry);
3217
3218 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry)) {
3219 if (LIM_IS_AP_ROLE(session_entry)) {
3220 if (session_entry->gLimProtectionControl !=
3221 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
3222 lim_decide_ap_protection_on_delete(mac_ctx,
3223 sta_ds, &beacon_params, session_entry);
3224 }
3225
3226 if (LIM_IS_IBSS_ROLE(session_entry))
3227 lim_ibss_decide_protection_on_delete(mac_ctx, sta_ds,
3228 &beacon_params, session_entry);
3229
3230 lim_decide_short_preamble(mac_ctx, sta_ds, &beacon_params,
3231 session_entry);
3232 lim_decide_short_slot(mac_ctx, sta_ds, &beacon_params,
3233 session_entry);
3234
3235 /* Send message to HAL about beacon parameter change. */
3236 lim_log(mac_ctx, LOGW, FL("param bitmap = %d "),
3237 beacon_params.paramChangeBitmap);
3238 if (beacon_params.paramChangeBitmap &&
3239 (false ==
3240 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
3241 sch_set_fixed_beacon_fields(mac_ctx, session_entry);
3242 lim_send_beacon_params(mac_ctx, &beacon_params,
3243 session_entry);
3244 }
3245#ifdef WLAN_FEATURE_11W
3246 tx_timer_delete(&sta_ds->pmfSaQueryTimer);
3247#endif
3248 }
3249
3250 if (dph_delete_hash_entry(mac_ctx, sta_addr, sta_id,
3251 &session_entry->dph.dphHashTable) != eSIR_SUCCESS)
3252 lim_log(mac_ctx, LOGP, FL("error deleting hash entry"));
3253}
3254
3255/**
3256 * lim_check_and_announce_join_success()- function to check if the received
3257 * Beacon/Probe Response is from the BSS that we're attempting to join.
3258 * @mac: pointer to global mac structure
3259 * @beacon_probe_rsp: pointer to reveived beacon/probe response frame
3260 * @header: pointer to received management frame header
3261 * @session_entry: pe session entry
3262 *
3263 * This function is called upon receiving Beacon/Probe Response
3264 * frame in WT_JOIN_BEACON_STATE to check if the received
3265 * Beacon/Probe Response is from the BSS that we're attempting
3266 * to join.
3267 * If the Beacon/Probe Response is indeed from the BSS we're
3268 * attempting to join, join success is sent to SME.
3269 *
3270 * Return: none
3271 */
3272
3273void
3274lim_check_and_announce_join_success(tpAniSirGlobal mac_ctx,
3275 tSirProbeRespBeacon *beacon_probe_rsp, tpSirMacMgmtHdr header,
3276 tpPESession session_entry)
3277{
3278 tSirMacSSid current_ssid;
3279 tLimMlmJoinCnf mlm_join_cnf;
3280 uint32_t val = 0;
3281 uint32_t *noa_duration_from_beacon = NULL;
3282 uint32_t *noa2_duration_from_beacon = NULL;
3283 uint32_t noa;
3284 uint32_t total_num_noa_desc = 0;
Kiran Kumar Lokere92d11bf2015-12-15 16:51:18 -08003285 uint32_t selfStaDot11Mode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303287 qdf_mem_copy(current_ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 session_entry->ssId.ssId, session_entry->ssId.length);
3289
3290 current_ssid.length = (uint8_t) session_entry->ssId.length;
3291
3292 /*
3293 * Check for SSID only in probe response. Beacons may not carry
3294 * SSID information in hidden SSID case
3295 */
3296 if (((SIR_MAC_MGMT_FRAME == header->fc.type) &&
3297 (SIR_MAC_MGMT_PROBE_RSP == header->fc.subType)) &&
3298 current_ssid.length &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303299 (qdf_mem_cmp((uint8_t *) &beacon_probe_rsp->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 (uint8_t *) &current_ssid,
3301 (uint8_t) (1 + current_ssid.length)))) {
3302 /*
3303 * Received SSID does not match with the one we've.
3304 * Ignore received Beacon frame
3305 */
3306 lim_log(mac_ctx, LOG1,
3307 FL("SSID received in Beacon does not match"));
3308#ifdef WLAN_DEBUG
3309 mac_ctx->lim.gLimBcnSSIDMismatchCnt++;
3310#endif
3311 return;
3312 }
3313
3314 if (!(LIM_IS_BT_AMP_STA_ROLE(session_entry) ||
3315 LIM_IS_STA_ROLE(session_entry)))
3316 return;
3317
3318 lim_log(mac_ctx, LOG1,
3319 FL("Received Beacon/PR with matching BSSID:%pM PESessionID %d"),
3320 session_entry->bssId, session_entry->peSessionId);
3321
3322 /* Deactivate Join Failure timer */
3323 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
3324 /* Deactivate Periodic Join timer */
3325 lim_deactivate_and_change_timer(mac_ctx,
3326 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
3327
Anurag Chouhan6d760662016-02-20 16:05:43 +05303328 if (QDF_P2P_CLIENT_MODE == session_entry->pePersona &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.present) {
3330
3331 noa_duration_from_beacon = (uint32_t *)
3332 (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3333
3334 if (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3335 total_num_noa_desc =
3336 beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.
3337 num_NoADesc / SIZE_OF_NOA_DESCRIPTOR;
3338
3339 noa = *noa_duration_from_beacon;
3340
3341 if (total_num_noa_desc > 1) {
3342 noa2_duration_from_beacon = (uint32_t *)
3343 (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.NoADesc +
3344 SIZE_OF_NOA_DESCRIPTOR + 1);
3345 noa += *noa2_duration_from_beacon;
3346 }
3347
3348 /*
3349 * If MAX Noa exceeds 3 secs we will consider only 3 secs to
3350 * avoid arbitary values in noa duration field
3351 */
3352 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ?
3353 MAX_NOA_PERIOD_IN_MICROSECS : noa;
3354 noa = noa / 1000; /* Convert to ms */
3355
3356 if (wlan_cfg_get_int(mac_ctx,
3357 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT, &val) ==
3358 eSIR_SUCCESS) {
3359 session_entry->defaultAuthFailureTimeout = val;
3360 cfg_set_int(mac_ctx,
3361 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
3362 val + noa);
3363 }
3364 } else {
3365 session_entry->defaultAuthFailureTimeout = 0;
3366 }
3367
3368 /* Update Beacon Interval at CFG database */
3369
3370 if (beacon_probe_rsp->HTCaps.present)
3371 lim_update_sta_run_time_ht_capability(mac_ctx,
3372 &beacon_probe_rsp->HTCaps);
3373 if (beacon_probe_rsp->HTInfo.present)
3374 lim_update_sta_run_time_ht_info(mac_ctx,
3375 &beacon_probe_rsp->HTInfo, session_entry);
3376 session_entry->limMlmState = eLIM_MLM_JOINED_STATE;
3377 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
3378 session_entry->peSessionId, eLIM_MLM_JOINED_STATE));
3379
3380 /*
3381 * update the capability info based on recently received beacon/probe
3382 * response frame
3383 */
3384 session_entry->limCurrentBssCaps =
3385 lim_get_u16((uint8_t *)&beacon_probe_rsp->capabilityInfo);
3386
3387 /*
3388 * Announce join success by sending
3389 * Join confirm to SME.
3390 */
3391 mlm_join_cnf.resultCode = eSIR_SME_SUCCESS;
3392 mlm_join_cnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3393 /* Update PE sessionId */
3394 mlm_join_cnf.sessionId = session_entry->peSessionId;
3395 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
3396 (uint32_t *) &mlm_join_cnf);
3397
Kiran Kumar Lokere92d11bf2015-12-15 16:51:18 -08003398 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
3399
3400 if ((IS_DOT11_MODE_VHT(selfStaDot11Mode)) &&
3401 beacon_probe_rsp->vendor2_ie.VHTCaps.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 session_entry->is_vendor_specific_vhtcaps = true;
3403 session_entry->vendor_specific_vht_ie_type =
3404 beacon_probe_rsp->vendor2_ie.type;
3405 session_entry->vendor_specific_vht_ie_sub_type =
3406 beacon_probe_rsp->vendor2_ie.sub_type;
3407 lim_log(mac_ctx, LOG1, FL(
3408 "VHT caps are present in vendor specific IE"));
3409 }
3410}
3411
3412/**
3413 * lim_extract_ap_capabilities()
3414 *
3415 ***FUNCTION:
3416 * This function is called to extract all of the AP's capabilities
3417 * from the IEs received from it in Beacon/Probe Response frames
3418 *
3419 ***LOGIC:
3420 * This routine mimics the lim_extract_ap_capability() API. The difference here
3421 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3422 * left to the caller of this API to use this info as required
3423 *
3424 ***ASSUMPTIONS:
3425 * NA
3426 *
3427 ***NOTE:
3428 *
3429 * @param pMac Pointer to Global MAC structure
3430 * @param pIE Pointer to starting IE in Beacon/Probe Response
3431 * @param ieLen Length of all IEs combined
3432 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3433 * populated
3434 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3435 */
3436tSirRetStatus lim_extract_ap_capabilities(tpAniSirGlobal pMac,
3437 uint8_t *pIE,
3438 uint16_t ieLen,
3439 tpSirProbeRespBeacon beaconStruct)
3440{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303441 qdf_mem_set((uint8_t *) beaconStruct, sizeof(tSirProbeRespBeacon), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442
3443 PELOG3(lim_log(pMac, LOG3,
3444 FL
3445 ("In lim_extract_ap_capabilities: The IE's being received are:"));
3446 sir_dump_buf(pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen);
3447 )
3448 /* Parse the Beacon IE's, Don't try to parse if we dont have anything in IE */
3449 if (ieLen > 0) {
3450 if (eSIR_SUCCESS !=
3451 sir_parse_beacon_ie(pMac, beaconStruct, pIE,
3452 (uint32_t) ieLen)) {
3453 lim_log(pMac, LOGE,
3454 FL("APCapExtract: Beacon parsing error!"));
3455 return eSIR_FAILURE;
3456 }
3457 }
3458
3459 return eSIR_SUCCESS;
3460}
3461
3462/**
3463 * lim_del_bss()
3464 *
3465 ***FUNCTION:
3466 * This function is called to delete BSS context at hardware
3467 * whenever a STA is disassociated
3468 *
3469 ***LOGIC:
3470 *
3471 ***ASSUMPTIONS:
3472 * NA
3473 *
3474 ***NOTE:
3475 * NA
3476 *
3477 * @param pMac - Pointer to Global MAC structure
3478 * @param pStaDs - Pointer to the STA datastructure created by
3479 * LIM and maintained by DPH
3480 * @return retCode - Indicates success or failure return code
3481 */
3482
3483tSirRetStatus
3484lim_del_bss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, uint16_t bssIdx,
3485 tpPESession psessionEntry)
3486{
3487 tpDeleteBssParams pDelBssParams = NULL;
3488 tSirMsgQ msgQ;
3489 tSirRetStatus retCode = eSIR_SUCCESS;
3490
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303491 pDelBssParams = qdf_mem_malloc(sizeof(tDeleteBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 if (NULL == pDelBssParams) {
3493 lim_log(pMac, LOGP,
3494 FL("Unable to allocate memory during ADD_BSS"));
3495 return eSIR_MEM_ALLOC_FAILED;
3496 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303497 qdf_mem_set((uint8_t *) pDelBssParams, sizeof(tDeleteBssParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498
3499 pDelBssParams->sessionId = psessionEntry->peSessionId; /* update PE session Id */
3500
3501 /* DPH was storing the AssocID in staID field, */
3502 /* staID is actually assigned by HAL when AddSTA message is sent. */
3503 if (pStaDs != NULL) {
3504 pDelBssParams->bssIdx = pStaDs->bssId;
3505 pStaDs->valid = 0;
3506 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3507 } else
3508 pDelBssParams->bssIdx = bssIdx;
3509 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3510 MTRACE(mac_trace
3511 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
3512 eLIM_MLM_WT_DEL_BSS_RSP_STATE));
3513
3514 if ((psessionEntry->peSessionId ==
3515 pMac->lim.limTimers.gLimJoinFailureTimer.sessionId)
3516 && (true ==
3517 tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer))) {
3518 lim_deactivate_and_change_timer(pMac, eLIM_JOIN_FAIL_TIMER);
3519 }
3520
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303521 pDelBssParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 pDelBssParams->respReqd = 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303523 qdf_mem_copy(pDelBssParams->bssid, psessionEntry->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 sizeof(tSirMacAddr));
3525 pDelBssParams->smesessionId = psessionEntry->smeSessionId;
3526 PELOGW(lim_log
3527 (pMac, LOGW,
3528 FL("Sessionid %d : Sending HAL_DELETE_BSS_REQ "
3529 "for bss idx: %X BSSID:" MAC_ADDRESS_STR),
3530 pDelBssParams->sessionId, pDelBssParams->bssIdx,
3531 MAC_ADDR_ARRAY(psessionEntry->bssId));
3532 )
3533 /* we need to defer the message until we get the response back from HAL. */
3534 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3535
3536 msgQ.type = WMA_DELETE_BSS_REQ;
3537 msgQ.reserved = 0;
3538 msgQ.bodyptr = pDelBssParams;
3539 msgQ.bodyval = 0;
3540
3541 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
3542
3543 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3544 if (eSIR_SUCCESS != retCode) {
3545 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3546 lim_log(pMac, LOGE,
3547 FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"),
3548 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303549 qdf_mem_free(pDelBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 }
3551
3552 return retCode;
3553}
3554
3555/**
3556 * lim_update_vhtcaps_assoc_resp : Update VHT caps in assoc response.
3557 * @mac_ctx Pointer to Global MAC structure
3558 * @pAddBssParams: parameters required for add bss params.
3559 * @vht_caps: VHT capabilities.
3560 * @psessionEntry : session entry.
3561 *
3562 * Return : void
3563 */
3564void lim_update_vhtcaps_assoc_resp(tpAniSirGlobal mac_ctx,
3565 tpAddBssParams pAddBssParams,
3566 tDot11fIEVHTCaps *vht_caps, tpPESession psessionEntry)
3567{
3568 pAddBssParams->staContext.vht_caps =
3569 ((vht_caps->maxMPDULen <<
3570 SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
3571 (vht_caps->supportedChannelWidthSet <<
3572 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
3573 (vht_caps->ldpcCodingCap <<
3574 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
3575 (vht_caps->shortGI80MHz <<
3576 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
3577 (vht_caps->shortGI160and80plus80MHz <<
3578 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
3579 (vht_caps->txSTBC <<
3580 SIR_MAC_VHT_CAP_TXSTBC) |
3581 (vht_caps->rxSTBC <<
3582 SIR_MAC_VHT_CAP_RXSTBC) |
3583 (vht_caps->suBeamFormerCap <<
3584 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
3585 (vht_caps->suBeamformeeCap <<
3586 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
3587 (vht_caps->csnofBeamformerAntSup <<
3588 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
3589 (vht_caps->numSoundingDim <<
3590 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
3591 (vht_caps->muBeamformerCap <<
3592 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
3593 (vht_caps->muBeamformeeCap <<
3594 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
3595 (vht_caps->vhtTXOPPS <<
3596 SIR_MAC_VHT_CAP_TXOPPS) |
3597 (vht_caps->htcVHTCap <<
3598 SIR_MAC_VHT_CAP_HTC_CAP) |
3599 (vht_caps->maxAMPDULenExp <<
3600 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
3601 (vht_caps->vhtLinkAdaptCap <<
3602 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
3603 (vht_caps->rxAntPattern <<
3604 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
3605 (vht_caps->txAntPattern <<
3606 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
3607 (vht_caps->reserved1 <<
3608 SIR_MAC_VHT_CAP_RESERVED2));
3609
3610 pAddBssParams->staContext.maxAmpduSize =
3611 SIR_MAC_GET_VHT_MAX_AMPDU_EXPO(
3612 pAddBssParams->staContext.vht_caps);
3613
3614 lim_log(mac_ctx, LOG1,
3615 FL("Updating VHT caps in assoc Response"));
3616}
3617
3618/**
3619 * lim_update_vht_oper_assoc_resp : Update VHT Operations in assoc response.
3620 * @mac_ctx Pointer to Global MAC structure
3621 * @pAddBssParams: parameters required for add bss params.
3622 * @vht_oper: VHT Operations to update.
3623 * @psessionEntry : session entry.
3624 *
3625 * Return : void
3626 */
3627void lim_update_vht_oper_assoc_resp(tpAniSirGlobal mac_ctx,
3628 tpAddBssParams pAddBssParams,
3629 tDot11fIEVHTOperation *vht_oper, tpPESession psessionEntry)
3630{
3631 if (vht_oper->chanWidth &&
3632 psessionEntry->ch_width) {
3633 pAddBssParams->ch_width = vht_oper->chanWidth + 1;
3634
3635 pAddBssParams->ch_center_freq_seg0 =
3636 vht_oper->chanCenterFreqSeg1;
3637
3638 pAddBssParams->ch_center_freq_seg1 =
3639 vht_oper->chanCenterFreqSeg2;
3640 }
3641 lim_log(mac_ctx, LOG1,
3642 FL("Updating VHT Operation in assoc Response"));
3643}
3644
3645
3646/**
3647 * limSendAddBss()
3648 *
3649 ***FUNCTION:
3650 *
3651 ***LOGIC:
3652 * 1) LIM receives eWNI_SME_JOIN_REQ
3653 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3654 * SIR_HAL_ADD_BSS_REQ to HAL
3655 *
3656 ***ASSUMPTIONS:
3657 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3658 * ADD BSS parameters can be obtained from two sources:
3659 * 1) pMac->lim.gLimMlmJoinReq
3660 * 2) beaconStruct, passed as paramter
3661 * So, if a reqd parameter is found in bssDescriptions
3662 * then it is given preference over beaconStruct
3663 *
3664 ***NOTE:
3665 *
3666 * @param pMac Pointer to Global MAC structure
3667 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3668 * beaconstruct Has the ProbeRsp/Beacon structured details
3669 * bssDescription bssDescription passed to PE from the SME
3670 * @return None
3671 */
3672
3673tSirRetStatus lim_sta_send_add_bss(tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3674 tpSchBeaconStruct pBeaconStruct,
3675 tpSirBssDescription bssDescription,
3676 uint8_t updateEntry, tpPESession psessionEntry)
3677{
3678 tSirMsgQ msgQ;
3679 tpAddBssParams pAddBssParams = NULL;
3680 uint32_t retCode;
3681 tpDphHashNode pStaDs = NULL;
3682 uint8_t chanWidthSupp = 0;
3683 uint32_t shortGi20MhzSupport;
3684 uint32_t shortGi40MhzSupport;
3685 uint32_t enableTxBF20MHz;
3686 tDot11fIEVHTCaps *vht_caps = NULL;
3687 tDot11fIEVHTOperation *vht_oper = NULL;
3688 tAddStaParams *sta_context;
3689
3690 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303691 pAddBssParams = qdf_mem_malloc(sizeof(tAddBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692 if (NULL == pAddBssParams) {
3693 lim_log(pMac, LOGP,
3694 FL("Unable to allocate memory during ADD_BSS"));
3695 retCode = eSIR_MEM_ALLOC_FAILED;
3696 goto returnFailure;
3697 } else
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303698 qdf_mem_set((uint8_t *) pAddBssParams, sizeof(tAddBssParams),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 0);
3700
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303701 qdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702 sizeof(tSirMacAddr));
3703 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303704 qdf_mem_copy(pAddBssParams->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
3706
3707 lim_log(pMac, LOG1,
3708 FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
3709 psessionEntry->smeSessionId, updateEntry,
3710 GET_LIM_SYSTEM_ROLE(psessionEntry));
3711
3712 lim_log(pMac, LOG1, FL("BSSID: " MAC_ADDRESS_STR),
3713 MAC_ADDR_ARRAY(pAddBssParams->bssId));
3714
3715 if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE) {
3716 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3717 } else {
3718 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3719 }
3720
3721 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3722
3723 /* Update PE session ID */
3724 pAddBssParams->sessionId = psessionEntry->peSessionId;
3725
3726 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3727
3728 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3729 pAddBssParams->updateBss = updateEntry;
3730
3731 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3732 pAddBssParams->cfParamSet.cfpPeriod =
3733 pBeaconStruct->cfParamSet.cfpPeriod;
3734 pAddBssParams->cfParamSet.cfpMaxDuration =
3735 pBeaconStruct->cfParamSet.cfpMaxDuration;
3736 pAddBssParams->cfParamSet.cfpDurRemaining =
3737 pBeaconStruct->cfParamSet.cfpDurRemaining;
3738
3739 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303740 qdf_mem_copy(pAddBssParams->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 pAssocRsp->supportedRates.rate,
3742 pAssocRsp->supportedRates.numRates);
3743
3744 if (IS_DOT11_MODE_11B(psessionEntry->dot11mode) &&
3745 bssDescription->nwType != eSIR_11B_NW_TYPE) {
3746 pAddBssParams->nwType = eSIR_11B_NW_TYPE;
3747 } else {
3748 pAddBssParams->nwType = bssDescription->nwType;
3749 }
3750
3751 pAddBssParams->shortSlotTimeSupported =
3752 (uint8_t) pAssocRsp->capabilityInfo.shortSlotTime;
3753 pAddBssParams->llaCoexist =
3754 (uint8_t) psessionEntry->beaconParams.llaCoexist;
3755 pAddBssParams->llbCoexist =
3756 (uint8_t) psessionEntry->beaconParams.llbCoexist;
3757 pAddBssParams->llgCoexist =
3758 (uint8_t) psessionEntry->beaconParams.llgCoexist;
3759 pAddBssParams->ht20Coexist =
3760 (uint8_t) psessionEntry->beaconParams.ht20Coexist;
3761
3762 lim_log(pMac, LOG2, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
3763 "cfpCount: %d"), pAddBssParams->bssType,
3764 pAddBssParams->beaconInterval, pAddBssParams->dtimPeriod,
3765 pAddBssParams->cfParamSet.cfpCount);
3766
3767 lim_log(pMac, LOG2,
3768 FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
3769 " %d numRates: %d "), pAddBssParams->cfParamSet.cfpPeriod,
3770 pAddBssParams->cfParamSet.cfpMaxDuration,
3771 pAddBssParams->cfParamSet.cfpDurRemaining,
3772 pAddBssParams->rateSet.numRates);
3773
3774 lim_log(pMac, LOG2, FL("nwType:%d shortSlotTimeSupported: %d"
3775 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
3776 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
3777 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
3778 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
3779
3780 pAddBssParams->dot11_mode = psessionEntry->dot11mode;
3781 lim_log(pMac, LOG2, FL("dot11_mode:%d"), pAddBssParams->dot11_mode);
3782
3783 /* Use the advertised capabilities from the received beacon/PR */
3784
3785 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
3786 && (pAssocRsp->HTCaps.present)) {
3787 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
3788 lim_log(pMac, LOG2, FL("htCapable: %d"),
3789 pAddBssParams->htCapable);
3790 if (pBeaconStruct->HTInfo.present) {
3791 pAddBssParams->htOperMode =
3792 (tSirMacHTOperatingMode) pAssocRsp->HTInfo.opMode;
3793 pAddBssParams->dualCTSProtection =
3794 (uint8_t) pAssocRsp->HTInfo.dualCTSProtection;
3795 chanWidthSupp =
3796 lim_get_ht_capability(pMac,
3797 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
3798 psessionEntry);
3799 if ((pAssocRsp->HTCaps.supportedChannelWidthSet)
3800 && (chanWidthSupp)) {
3801 pAddBssParams->ch_width = (uint8_t)
3802 pAssocRsp->HTInfo.recommendedTxWidthSet;
3803 if (pAssocRsp->HTInfo.secondaryChannelOffset ==
3804 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
3805 pAddBssParams->ch_center_freq_seg0 =
3806 bssDescription->channelId + 2;
3807 else if (pAssocRsp->HTInfo.secondaryChannelOffset ==
3808 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
3809 pAddBssParams->ch_center_freq_seg0 =
3810 bssDescription->channelId - 2;
3811 } else {
3812 pAddBssParams->ch_width = CH_WIDTH_20MHZ;
3813 pAddBssParams->ch_center_freq_seg0 = 0;
3814 }
3815 pAddBssParams->llnNonGFCoexist =
3816 (uint8_t) pAssocRsp->HTInfo.nonGFDevicesPresent;
3817 pAddBssParams->fLsigTXOPProtectionFullSupport =
3818 (uint8_t) pAssocRsp->HTInfo.
3819 lsigTXOPProtectionFullSupport;
3820 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
3821
3822 lim_log(pMac, LOGE,
3823 FL("htOperMode: %d dualCTSProtection: %d txChannelWidth: %d center_freq_0: %d "),
3824 pAddBssParams->htOperMode,
3825 pAddBssParams->dualCTSProtection,
3826 pAddBssParams->ch_width,
3827 pAddBssParams->ch_center_freq_seg0);
3828
3829 lim_log(pMac, LOG2, FL("llnNonGFCoexist: %d "
3830 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
3831 pAddBssParams->llnNonGFCoexist,
3832 pAddBssParams->fLsigTXOPProtectionFullSupport,
3833 pAddBssParams->fRIFSMode);
3834 }
3835 }
3836
3837 pAddBssParams->currentOperChannel = bssDescription->channelId;
3838 lim_log(pMac, LOGE, FL("currentOperChannel %d"),
3839 pAddBssParams->currentOperChannel);
3840 if (psessionEntry->vhtCapability && (pAssocRsp->VHTCaps.present)) {
3841 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3842 vht_caps = &pAssocRsp->VHTCaps;
3843 vht_oper = &pAssocRsp->VHTOperation;
3844 } else if (psessionEntry->vhtCapability &&
3845 pAssocRsp->vendor2_ie.VHTCaps.present){
3846 pAddBssParams->vhtCapable =
3847 pAssocRsp->vendor2_ie.VHTCaps.present;
3848 lim_log(pMac, LOG1,
3849 FL("VHT Caps and Operation are present in vendor Specfic IE"));
3850 vht_caps = &pAssocRsp->vendor2_ie.VHTCaps;
3851 vht_oper = &pAssocRsp->vendor2_ie.VHTOperation;
3852 } else {
3853 pAddBssParams->vhtCapable = 0;
3854 }
3855 if (pAddBssParams->vhtCapable) {
3856 if (vht_oper != NULL)
3857 lim_update_vht_oper_assoc_resp(pMac, pAddBssParams,
3858 vht_oper, psessionEntry);
3859 if (vht_caps != NULL)
3860 lim_update_vhtcaps_assoc_resp(pMac, pAddBssParams,
3861 vht_caps, psessionEntry);
3862 }
3863
3864 lim_log(pMac, LOGE, FL("vhtCapable %d TxChannelWidth %d center_freq_0 %d center_freq_1 %d"),
3865 pAddBssParams->vhtCapable, pAddBssParams->ch_width,
3866 pAddBssParams->ch_center_freq_seg0,
3867 pAddBssParams->ch_center_freq_seg1);
3868
3869 /*
3870 * Populate the STA-related parameters here
3871 * Note that the STA here refers to the AP
3872 * staType = PEER
3873 */
3874 sta_context = &pAddBssParams->staContext;
3875 /* Identifying AP as an STA */
3876 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
3877
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303878 qdf_mem_copy(pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879 bssDescription->bssId, sizeof(tSirMacAddr));
3880 pAddBssParams->staContext.listenInterval =
3881 bssDescription->beaconInterval;
3882
3883 /* Fill Assoc id from the dph table */
3884 pStaDs = dph_lookup_hash_entry(pMac, pAddBssParams->staContext.bssId,
3885 &pAddBssParams->staContext.assocId,
3886 &psessionEntry->dph.dphHashTable);
3887 if (pStaDs == NULL) {
3888 lim_log(pMac, LOGE, FL(
3889 "Couldn't get assoc id for " "MAC ADDR: "
3890 MAC_ADDRESS_STR),
3891 MAC_ADDR_ARRAY(
3892 pAddBssParams->staContext.staMac));
3893 return eSIR_FAILURE;
3894 }
3895
3896 pAddBssParams->staContext.uAPSD =
3897 psessionEntry->gUapsdPerAcBitmask;
3898
3899 pAddBssParams->staContext.maxSPLen = 0;
3900 pAddBssParams->staContext.shortPreambleSupported =
3901 (uint8_t) pAssocRsp->capabilityInfo.shortPreamble;
3902 pAddBssParams->staContext.updateSta = updateEntry;
3903
3904 lim_log(pMac, LOG2, FL("StaContext: " MAC_ADDRESS_STR
3905 " shortPreambleSupported: %d"),
3906 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
3907 pAddBssParams->staContext.shortPreambleSupported);
3908
3909 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
3910 && pBeaconStruct->HTCaps.present) {
3911 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3912 pAddBssParams->staContext.htCapable = 1;
3913 pAddBssParams->staContext.greenFieldCapable =
3914 (uint8_t) pAssocRsp->HTCaps.greenField;
3915 pAddBssParams->staContext.lsigTxopProtection =
3916 (uint8_t) pAssocRsp->HTCaps.lsigTXOPProtection;
3917 lim_log(pMac, LOG2, FL(
3918 "StaCtx: htCap %d GFcap %d lsigTxopProtn %d"),
3919 pAddBssParams->staContext.htCapable,
3920 pAddBssParams->staContext.greenFieldCapable,
3921 pAddBssParams->staContext.lsigTxopProtection);
3922 if (psessionEntry->vhtCapability &&
3923 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
3924 IS_BSS_VHT_CAPABLE(
3925 pBeaconStruct->vendor2_ie.VHTCaps))) {
3926 pAddBssParams->staContext.vhtCapable = 1;
3927 pAddBssParams->staContext.vhtSupportedRxNss =
3928 pStaDs->vhtSupportedRxNss;
3929 if (pAssocRsp->VHTCaps.present)
3930 vht_caps = &pAssocRsp->VHTCaps;
3931 else if (pAssocRsp->vendor2_ie.VHTCaps.present) {
3932 vht_caps = &pAssocRsp->vendor2_ie.VHTCaps;
3933 lim_log(pMac, LOG1, FL(
3934 "VHT Caps are in vendor Specfic IE"));
3935 }
3936
3937 if ((vht_caps != NULL) && (vht_caps->suBeamFormerCap ||
3938 vht_caps->muBeamformerCap) &&
3939 psessionEntry->txBFIniFeatureEnabled)
3940 sta_context->vhtTxBFCapable = 1;
3941
3942 if ((vht_caps != NULL) && vht_caps->muBeamformerCap &&
3943 psessionEntry->txMuBformee)
3944 sta_context->vhtTxMUBformeeCapable = 1;
3945 if ((vht_caps != NULL) && vht_caps->suBeamformeeCap &&
3946 psessionEntry->enable_su_tx_bformer)
3947 sta_context->enable_su_tx_bformer = 1;
3948 }
3949
3950 if ((pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3951 (chanWidthSupp)) {
3952 pAddBssParams->staContext.ch_width = (uint8_t)
3953 pAssocRsp->HTInfo.recommendedTxWidthSet;
3954 if (pAssocRsp->VHTCaps.present)
3955 vht_oper = &pAssocRsp->VHTOperation;
3956 else if (pAssocRsp->vendor2_ie.VHTCaps.present) {
3957 vht_oper = &pAssocRsp->vendor2_ie.VHTOperation;
3958 lim_log(pMac, LOG1, FL(
3959 "VHT Op IE is in vendor Specfic IE"));
3960 }
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08003961 /*
3962 * in limExtractApCapability function intersection of FW
3963 * advertised channel width and AP advertised channel
3964 * width has been taken into account for calculating
3965 * psessionEntry->ch_width
3966 */
3967 pAddBssParams->staContext.ch_width =
3968 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969
3970 lim_log(pMac, LOGE, FL(
3971 "StaCtx: vhtCap %d ChBW %d TxBF %d"),
3972 pAddBssParams->staContext.vhtCapable,
3973 pAddBssParams->staContext.ch_width,
3974 sta_context->vhtTxBFCapable);
3975 lim_log(pMac, LOGE, FL("StaContext su_tx_bfer %d"),
3976 sta_context->enable_su_tx_bformer);
3977 } else {
3978 sta_context->ch_width = CH_WIDTH_20MHZ;
3979 if ((IS_SIR_STATUS_SUCCESS(
3980 wlan_cfg_get_int(pMac,
3981 WNI_CFG_VHT_ENABLE_TXBF_20MHZ,
3982 &enableTxBF20MHz))) &&
3983 (false == enableTxBF20MHz))
3984 sta_context->vhtTxBFCapable = 0;
3985 }
3986 pAddBssParams->staContext.mimoPS =
3987 (tSirMacHTMIMOPowerSaveState)
3988 pAssocRsp->HTCaps.mimoPowerSave;
3989 pAddBssParams->staContext.maxAmsduSize =
3990 (uint8_t) pAssocRsp->HTCaps.maximalAMSDUsize;
3991 pAddBssParams->staContext.maxAmpduDensity =
3992 pAssocRsp->HTCaps.mpduDensity;
3993 pAddBssParams->staContext.fDsssCckMode40Mhz =
3994 (uint8_t) pAssocRsp->HTCaps.dsssCckMode40MHz;
3995 /*
3996 * We will check gShortGI20Mhz and gShortGI40Mhz from
3997 * ini file. if they are set then we will use what ever
3998 * Assoc response coming from AP supports. If these
3999 * values are set as 0 in ini file then we will
4000 * hardcode this values to 0.
4001 */
4002 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int
4003 (pMac, WNI_CFG_SHORT_GI_20MHZ,
4004 &shortGi20MhzSupport))) {
4005 if (true == shortGi20MhzSupport) {
4006 pAddBssParams->staContext.
4007 fShortGI20Mhz =
4008 (uint8_t) pAssocRsp->HTCaps.
4009 shortGI20MHz;
4010 } else {
4011 pAddBssParams->staContext.
4012 fShortGI20Mhz = false;
4013 }
4014 } else {
4015 lim_log(pMac, LOGE, FL(
4016 "failed to get shortGI 20Mhz, set default"));
4017 pAddBssParams->staContext.fShortGI20Mhz =
4018 WNI_CFG_SHORT_GI_20MHZ_STADEF;
4019 }
4020
4021 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int
4022 (pMac, WNI_CFG_SHORT_GI_40MHZ,
4023 &shortGi40MhzSupport))) {
4024 if (true == shortGi40MhzSupport) {
4025 pAddBssParams->staContext.
4026 fShortGI40Mhz =
4027 (uint8_t) pAssocRsp->HTCaps.
4028 shortGI40MHz;
4029 } else {
4030 pAddBssParams->staContext.
4031 fShortGI40Mhz = false;
4032 }
4033 } else {
4034 lim_log(pMac, LOGE, FL(
4035 "failed to get shortGI 40Mhz, set default"));
4036 pAddBssParams->staContext.fShortGI40Mhz =
4037 WNI_CFG_SHORT_GI_40MHZ_STADEF;
4038 }
4039
4040 if (!pAddBssParams->staContext.vhtCapable)
4041 /* Use max ampd factor advertised in
4042 * HTCAP for non-vht connection */
4043 {
4044 pAddBssParams->staContext.maxAmpduSize =
4045 pAssocRsp->HTCaps.maxRxAMPDUFactor;
4046 } else if (pAddBssParams->staContext.maxAmpduSize <
4047 pAssocRsp->HTCaps.maxRxAMPDUFactor) {
4048 pAddBssParams->staContext.maxAmpduSize =
4049 pAssocRsp->HTCaps.maxRxAMPDUFactor;
4050 }
4051 if (pAddBssParams->staContext.vhtTxBFCapable
4052 && pMac->lim.disableLDPCWithTxbfAP) {
4053 pAddBssParams->staContext.htLdpcCapable = 0;
4054 pAddBssParams->staContext.vhtLdpcCapable = 0;
4055 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004056 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
4057 pAddBssParams->staContext.htLdpcCapable =
4058 (uint8_t) pAssocRsp->HTCaps.advCodingCap;
4059 else
4060 pAddBssParams->staContext.htLdpcCapable = 0;
4061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 if (pAssocRsp->VHTCaps.present)
4063 vht_caps = &pAssocRsp->VHTCaps;
4064 else if (pAssocRsp->vendor2_ie.VHTCaps.present) {
4065 vht_caps = &pAssocRsp->vendor2_ie.VHTCaps;
4066 lim_log(pMac, LOG1, FL(
4067 "VHT Caps is in vendor Specfic IE"));
4068 }
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004069 if (vht_caps != NULL &&
4070 (psessionEntry->txLdpcIniFeatureEnabled & 0x2))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 pAddBssParams->staContext.vhtLdpcCapable =
4072 (uint8_t) vht_caps->ldpcCodingCap;
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004073 else
4074 pAddBssParams->staContext.vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 }
4076
4077 if (pBeaconStruct->HTInfo.present)
4078 pAddBssParams->staContext.rifsMode =
4079 pAssocRsp->HTInfo.rifsMode;
4080
4081 lim_log(pMac, LOGE, FL(
4082 "StaCtx: ChBW %d mimoPS %d maxAmsduSize %d"),
4083 pAddBssParams->staContext.ch_width,
4084 pAddBssParams->staContext.mimoPS,
4085 pAddBssParams->staContext.maxAmsduSize);
4086
4087 lim_log(pMac, LOG2, FL(
4088 "maxAmpduDens %d CckMode40Mhz %d SGI20Mhz %d"),
4089 pAddBssParams->staContext.maxAmpduDensity,
4090 pAddBssParams->staContext.fDsssCckMode40Mhz,
4091 pAddBssParams->staContext.fShortGI20Mhz);
4092
4093 lim_log(pMac, LOG2, FL(
4094 "SGI40M %d maxAmpdu %d htLdpc %d vhtLdpc %d"),
4095 pAddBssParams->staContext.fShortGI40Mhz,
4096 pAddBssParams->staContext.maxAmpduSize,
4097 pAddBssParams->staContext.htLdpcCapable,
4098 pAddBssParams->staContext.vhtLdpcCapable);
4099 }
4100 pAddBssParams->staContext.smesessionId =
4101 psessionEntry->smeSessionId;
4102 pAddBssParams->staContext.wpa_rsn = pBeaconStruct->rsnPresent;
4103 pAddBssParams->staContext.wpa_rsn |=
4104 (pBeaconStruct->wpaPresent << 1);
4105 /* For OSEN Connection AP does not advertise RSN or WPA IE
4106 * so from the IEs we get from supplicant we get this info
4107 * so for FW to transmit EAPOL message 4 we shall set
4108 * wpa_rsn
4109 */
4110 if ((!pAddBssParams->staContext.wpa_rsn)
4111 && (psessionEntry->isOSENConnection))
4112 pAddBssParams->staContext.wpa_rsn = 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304113 qdf_mem_copy(&pAddBssParams->staContext.capab_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 &pAssocRsp->capabilityInfo,
4115 sizeof(pAddBssParams->staContext.capab_info));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304116 qdf_mem_copy(&pAddBssParams->staContext.ht_caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 (uint8_t *) &pAssocRsp->HTCaps + sizeof(uint8_t),
4118 sizeof(pAddBssParams->staContext.ht_caps));
4119
4120 /* If WMM IE or 802.11E IE is present then enable WMM */
4121 if ((psessionEntry->limWmeEnabled && pAssocRsp->wmeEdcaPresent) ||
4122 (psessionEntry->limQosEnabled && pAssocRsp->edcaPresent))
4123 pAddBssParams->staContext.wmmEnabled = 1;
4124 else
4125 pAddBssParams->staContext.wmmEnabled = 0;
4126
4127 /* Update the rates */
4128 pStaDs = dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
4129 &psessionEntry->dph.dphHashTable);
4130 if (pStaDs != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304131 qdf_mem_copy((uint8_t *) &pAddBssParams->staContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 supportedRates,
Kiran Kumar Lokere5899f432016-02-18 12:53:42 -08004133 (uint8_t *)&pStaDs->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 sizeof(tSirSupportedRates));
4135 } else
4136 lim_log(pMac, LOGE, FL(
4137 "could not Update the supported rates"));
4138 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4139
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
4141 lim_log(pMac, LOG2, FL("maxTxPower: %d"), pAddBssParams->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 /* FIXME_GEN4 - Any other value that can be used for initialization? */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304143 pAddBssParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 pAddBssParams->respReqd = true;
4145 /* update persona */
4146 pAddBssParams->halPersona = (uint8_t) psessionEntry->pePersona;
4147
Anurag Chouhan6d760662016-02-20 16:05:43 +05304148 if (QDF_P2P_CLIENT_MODE == psessionEntry->pePersona)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 pAddBssParams->staContext.p2pCapableSta = 1;
4150
4151 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
4152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 pAddBssParams->extSetStaKeyParamValid = 0;
4154 lim_log(pMac, LOG2, FL("extSetStaKeyParamValid: %d"),
4155 pAddBssParams->extSetStaKeyParamValid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156
4157#ifdef WLAN_FEATURE_11W
4158 if (psessionEntry->limRmfEnabled) {
4159 pAddBssParams->rmfEnabled = 1;
4160 pAddBssParams->staContext.rmfEnabled = 1;
4161 }
4162#endif
4163
4164 /* Set a new state for MLME */
4165 if (eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState)
4166 psessionEntry->limMlmState =
4167 eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
4168 else
4169 psessionEntry->limMlmState =
4170 eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
4171 MTRACE(mac_trace
4172 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
4173 psessionEntry->limMlmState));
4174
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004175 if (!pAddBssParams->staContext.htLdpcCapable)
4176 pAddBssParams->staContext.ht_caps &=
4177 ~(1 << SIR_MAC_HT_CAP_ADVCODING_S);
4178 if (!pAddBssParams->staContext.vhtLdpcCapable)
4179 pAddBssParams->staContext.vht_caps &=
4180 ~(1 << SIR_MAC_VHT_CAP_LDPC_CODING_CAP);
4181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 lim_log(pMac, LOG2, FL("staContext wmmEnabled: %d encryptType: %d "
4183 "p2pCapableSta: %d"),
4184 pAddBssParams->staContext.wmmEnabled,
4185 pAddBssParams->staContext.encryptType,
4186 pAddBssParams->staContext.p2pCapableSta);
4187
4188 lim_log(pMac, LOG2, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
4189 "LimMlm state to %d"),
4190 pAddBssParams->bSpectrumMgtEnabled, pAddBssParams->halPersona,
4191 psessionEntry->limMlmState);
4192 if (psessionEntry->isNonRoamReassoc)
4193 pAddBssParams->nonRoamReassoc = 1;
4194 pAddBssParams->nss = psessionEntry->nss;
4195 lim_log(pMac, LOG2, FL("nss value: %d"), pAddBssParams->nss);
4196
4197 /* we need to defer the message until we get the response back from HAL. */
4198 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4199
4200 msgQ.type = WMA_ADD_BSS_REQ;
4201 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4202 msgQ.reserved = 0;
4203 msgQ.bodyptr = pAddBssParams;
4204 msgQ.bodyval = 0;
4205
4206 lim_log(pMac, LOG1, FL("SessionId:%d Sending WMA_ADD_BSS_REQ"),
4207 psessionEntry->peSessionId);
4208 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
4209
4210 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4211 if (eSIR_SUCCESS != retCode) {
4212 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304213 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 lim_log(pMac, LOGE,
4215 FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
4216 retCode);
4217 goto returnFailure;
4218
4219 } else
4220 return retCode;
4221
4222returnFailure:
4223 /* Clean-up will be done by the caller... */
4224 return retCode;
4225}
4226
4227tSirRetStatus lim_sta_send_add_bss_pre_assoc(tpAniSirGlobal pMac, uint8_t updateEntry,
4228 tpPESession psessionEntry)
4229{
4230 tSirMsgQ msgQ;
4231 tpAddBssParams pAddBssParams = NULL;
4232 uint32_t retCode;
4233 tSchBeaconStruct *pBeaconStruct;
4234 uint8_t chanWidthSupp = 0;
4235 uint32_t shortGi20MhzSupport;
4236 uint32_t shortGi40MhzSupport;
4237 tDot11fIEVHTOperation *vht_oper = NULL;
4238 tDot11fIEVHTCaps *vht_caps = NULL;
4239
4240 tpSirBssDescription bssDescription =
4241 &psessionEntry->pLimJoinReq->bssDescription;
4242
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304243 pBeaconStruct = qdf_mem_malloc(sizeof(tSchBeaconStruct));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 if (NULL == pBeaconStruct) {
4245 lim_log(pMac, LOGE,
4246 FL("Unable to allocate memory during ADD_BSS"));
4247 return eSIR_MEM_ALLOC_FAILED;
4248 }
4249
4250 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304251 pAddBssParams = qdf_mem_malloc(sizeof(tAddBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 if (NULL == pAddBssParams) {
4253 lim_log(pMac, LOGP,
4254 FL("Unable to allocate memory during ADD_BSS"));
4255 retCode = eSIR_MEM_ALLOC_FAILED;
4256 goto returnFailure;
4257 }
4258
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304259 qdf_mem_set((uint8_t *) pAddBssParams, sizeof(tAddBssParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260
4261 lim_extract_ap_capabilities(pMac, (uint8_t *) bssDescription->ieFields,
4262 lim_get_ielen_from_bss_description(bssDescription),
4263 pBeaconStruct);
4264
4265 if (pMac->lim.gLimProtectionControl !=
4266 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
4267 lim_decide_sta_protection_on_assoc(pMac, pBeaconStruct,
4268 psessionEntry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304269 qdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 sizeof(tSirMacAddr));
4271
4272 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304273 qdf_mem_copy(pAddBssParams->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
4275 lim_log(pMac, LOG1,
4276 FL("sessionid: %d updateEntry = %d limsystemrole = %d "),
4277 psessionEntry->smeSessionId, updateEntry,
4278 GET_LIM_SYSTEM_ROLE(psessionEntry));
4279
4280 lim_log(pMac, LOG1, FL("BSSID: " MAC_ADDRESS_STR),
4281 MAC_ADDR_ARRAY(pAddBssParams->bssId));
4282 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
4283 * top of an already established Infra link. This lead to issues in
4284 * concurrent data transfer.
4285 */
4286
4287 pAddBssParams->bssType = psessionEntry->bssType; /* eSIR_INFRASTRUCTURE_MODE; */
4288 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
4289
4290 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
4291
4292 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
4293 pAddBssParams->updateBss = updateEntry;
4294
4295 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
4296 pAddBssParams->cfParamSet.cfpPeriod =
4297 pBeaconStruct->cfParamSet.cfpPeriod;
4298 pAddBssParams->cfParamSet.cfpMaxDuration =
4299 pBeaconStruct->cfParamSet.cfpMaxDuration;
4300 pAddBssParams->cfParamSet.cfpDurRemaining =
4301 pBeaconStruct->cfParamSet.cfpDurRemaining;
4302
4303 pAddBssParams->rateSet.numRates =
4304 pBeaconStruct->supportedRates.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304305 qdf_mem_copy(pAddBssParams->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 pBeaconStruct->supportedRates.rate,
4307 pBeaconStruct->supportedRates.numRates);
4308
4309 pAddBssParams->nwType = bssDescription->nwType;
4310
4311 pAddBssParams->shortSlotTimeSupported =
4312 (uint8_t) pBeaconStruct->capabilityInfo.shortSlotTime;
4313 pAddBssParams->llaCoexist =
4314 (uint8_t) psessionEntry->beaconParams.llaCoexist;
4315 pAddBssParams->llbCoexist =
4316 (uint8_t) psessionEntry->beaconParams.llbCoexist;
4317 pAddBssParams->llgCoexist =
4318 (uint8_t) psessionEntry->beaconParams.llgCoexist;
4319 pAddBssParams->ht20Coexist =
4320 (uint8_t) psessionEntry->beaconParams.ht20Coexist;
4321
4322 lim_log(pMac, LOG2, FL(" BSS Type %d Beacon Interval: %d dtimPeriod: %d "
4323 "cfpCount: %d"), pAddBssParams->bssType,
4324 pAddBssParams->beaconInterval, pAddBssParams->dtimPeriod,
4325 pAddBssParams->cfParamSet.cfpCount);
4326
4327 lim_log(pMac, LOG2,
4328 FL(" cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining:"
4329 " %d numRates: %d "), pAddBssParams->cfParamSet.cfpPeriod,
4330 pAddBssParams->cfParamSet.cfpMaxDuration,
4331 pAddBssParams->cfParamSet.cfpDurRemaining,
4332 pAddBssParams->rateSet.numRates);
4333
4334 lim_log(pMac, LOG2, FL("nwType:%d shortSlotTimeSupported: %d"
4335 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d"),
4336 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
4337 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
4338 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
4339 /* Use the advertised capabilities from the received beacon/PR */
4340 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
4341 && (pBeaconStruct->HTCaps.present)) {
4342 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
4343 lim_log(pMac, LOG2, FL("htCapable: %d"),
4344 pAddBssParams->htCapable);
4345 if (pBeaconStruct->HTInfo.present) {
4346 pAddBssParams->htOperMode =
4347 (tSirMacHTOperatingMode) pBeaconStruct->HTInfo.
4348 opMode;
4349 pAddBssParams->dualCTSProtection =
4350 (uint8_t) pBeaconStruct->HTInfo.dualCTSProtection;
4351
4352 chanWidthSupp =
4353 lim_get_ht_capability(pMac,
4354 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
4355 psessionEntry);
4356 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet)
4357 && (chanWidthSupp)) {
4358 pAddBssParams->ch_width =
4359 (uint8_t) pBeaconStruct->HTInfo.
4360 recommendedTxWidthSet;
4361 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
4362 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
4363 pAddBssParams->ch_center_freq_seg0 =
4364 bssDescription->channelId + 2;
4365
4366 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
4367 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
4368 pAddBssParams->ch_center_freq_seg0 =
4369 bssDescription->channelId - 2;
4370 } else {
4371 pAddBssParams->ch_width = CH_WIDTH_20MHZ;
4372 pAddBssParams->ch_center_freq_seg0 = 0;
4373 }
4374 pAddBssParams->llnNonGFCoexist =
4375 (uint8_t) pBeaconStruct->HTInfo.nonGFDevicesPresent;
4376 pAddBssParams->fLsigTXOPProtectionFullSupport =
4377 (uint8_t) pBeaconStruct->HTInfo.
4378 lsigTXOPProtectionFullSupport;
4379 pAddBssParams->fRIFSMode =
4380 pBeaconStruct->HTInfo.rifsMode;
4381
4382 lim_log(pMac, LOG2,
4383 FL("htOperMode: %d dualCTSProtection: %d txChannelWidthSet: %d center_freq_seg0: %d "),
4384 pAddBssParams->htOperMode,
4385 pAddBssParams->dualCTSProtection,
4386 pAddBssParams->txChannelWidthSet,
4387 pAddBssParams->ch_center_freq_seg0);
4388
4389 lim_log(pMac, LOG2, FL("llnNonGFCoexist: %d "
4390 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d"),
4391 pAddBssParams->llnNonGFCoexist,
4392 pAddBssParams->fLsigTXOPProtectionFullSupport,
4393 pAddBssParams->fRIFSMode);
4394 }
4395 }
4396
4397 pAddBssParams->currentOperChannel = bssDescription->channelId;
4398 lim_log(pMac, LOG2, FL("currentOperChannel %d"),
4399 pAddBssParams->currentOperChannel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400 if (psessionEntry->vhtCapability &&
4401 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
4402 IS_BSS_VHT_CAPABLE(pBeaconStruct->vendor2_ie.VHTCaps))) {
4403
4404 pAddBssParams->vhtCapable = 1;
4405 if (pBeaconStruct->VHTOperation.present)
4406 vht_oper = &pBeaconStruct->VHTOperation;
4407 else if (pBeaconStruct->vendor2_ie.VHTOperation.present) {
4408 vht_oper = &pBeaconStruct->vendor2_ie.VHTOperation;
4409 lim_log(pMac, LOG1,
4410 FL("VHT Operation is present in vendor Specfic IE"));
4411 }
4412
4413
4414 if ((vht_oper != NULL) &&
4415 vht_oper->chanWidth &&
4416 chanWidthSupp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 pAddBssParams->ch_center_freq_seg0 =
4418 vht_oper->chanCenterFreqSeg1;
4419 pAddBssParams->ch_center_freq_seg1 =
4420 vht_oper->chanCenterFreqSeg2;
4421 }
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08004422 /*
4423 * in limExtractApCapability function intersection of FW
4424 * advertised channel width and AP advertised channel width has
4425 * been taken into account for calculating
4426 * psessionEntry->ch_width
4427 */
4428 pAddBssParams->ch_width =
4429 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 pAddBssParams->staContext.maxAmpduSize =
4431 SIR_MAC_GET_VHT_MAX_AMPDU_EXPO(
4432 pAddBssParams->staContext.vht_caps);
4433 } else {
4434 pAddBssParams->vhtCapable = 0;
4435 }
4436 lim_log(pMac, LOGE, FL("vhtCapable %d vhtTxChannelWidthSet %d center_freq_seg0 - %d, center_freq_seg1 - %d"),
4437 pAddBssParams->vhtCapable, pAddBssParams->ch_width,
4438 pAddBssParams->ch_center_freq_seg0,
4439 pAddBssParams->ch_center_freq_seg1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440
4441 /*
4442 * Populate the STA-related parameters here
4443 * Note that the STA here refers to the AP
4444 */
4445 /* Identifying AP as an STA */
4446 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
4447
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304448 qdf_mem_copy(pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 bssDescription->bssId, sizeof(tSirMacAddr));
4450 pAddBssParams->staContext.listenInterval =
4451 bssDescription->beaconInterval;
4452
4453 pAddBssParams->staContext.assocId = 0;
4454 pAddBssParams->staContext.uAPSD = 0;
4455 pAddBssParams->staContext.maxSPLen = 0;
4456 pAddBssParams->staContext.shortPreambleSupported =
4457 (uint8_t) pBeaconStruct->capabilityInfo.shortPreamble;
4458 pAddBssParams->staContext.updateSta = updateEntry;
4459
4460 lim_log(pMac, LOG2, FL(
4461 "StaCtx: " MAC_ADDRESS_STR " shortPreamble: %d"),
4462 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
4463 pAddBssParams->staContext.shortPreambleSupported);
4464
4465 pAddBssParams->dot11_mode = psessionEntry->dot11mode;
4466 lim_log(pMac, LOG2, FL("dot11_mode:%d"),
4467 pAddBssParams->dot11_mode);
4468
4469 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
4470 && (pBeaconStruct->HTCaps.present)) {
4471 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
4472 pAddBssParams->staContext.htCapable = 1;
4473 pAddBssParams->staContext.greenFieldCapable =
4474 (uint8_t) pBeaconStruct->HTCaps.greenField;
4475 pAddBssParams->staContext.lsigTxopProtection =
4476 (uint8_t) pBeaconStruct->HTCaps.lsigTXOPProtection;
4477 lim_log(pMac, LOG2, FL(
4478 "StaCtx: htCap %d GFCap %d lsigTxopProtn %d"),
4479 pAddBssParams->staContext.htCapable,
4480 pAddBssParams->staContext.greenFieldCapable,
4481 pAddBssParams->staContext.lsigTxopProtection);
4482 if (psessionEntry->vhtCapability &&
4483 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
4484 IS_BSS_VHT_CAPABLE(
4485 pBeaconStruct->vendor2_ie.VHTCaps))) {
4486 pAddBssParams->staContext.vhtCapable = 1;
4487 if (pBeaconStruct->VHTCaps.present)
4488 vht_caps = &pBeaconStruct->VHTCaps;
4489 else if (pBeaconStruct->vendor2_ie.VHTCaps.present)
4490 vht_caps = &pBeaconStruct->vendor2_ie.VHTCaps;
4491
4492 if ((vht_caps != NULL) && (vht_caps->suBeamFormerCap ||
4493 vht_caps->muBeamformerCap) &&
4494 psessionEntry->txBFIniFeatureEnabled)
4495 pAddBssParams->staContext.vhtTxBFCapable = 1;
4496
4497 if ((vht_caps != NULL) && vht_caps->muBeamformerCap &&
4498 psessionEntry->txMuBformee)
4499 pAddBssParams->staContext.vhtTxMUBformeeCapable
4500 = 1;
4501 if ((vht_caps != NULL) && vht_caps->suBeamformeeCap &&
4502 psessionEntry->enable_su_tx_bformer)
4503 pAddBssParams->staContext.enable_su_tx_bformer
4504 = 1;
4505 lim_log(pMac, LOG2, FL("StaContext: su_tx_bfer %d"),
4506 pAddBssParams->staContext.enable_su_tx_bformer);
4507 }
4508 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
4509 (chanWidthSupp)) {
4510 pAddBssParams->staContext.ch_width =
4511 (uint8_t) pBeaconStruct->HTInfo.
4512 recommendedTxWidthSet;
4513 if ((vht_oper != NULL) &&
4514 pAddBssParams->staContext.vhtCapable &&
4515 vht_oper->chanWidth)
4516 pAddBssParams->staContext.ch_width =
4517 vht_oper->chanWidth + 1;
4518 lim_log(pMac, LOG2, FL(
4519 "StaCtx: vhtCap %d ch_bw %d TxBF %d"),
4520 pAddBssParams->staContext.vhtCapable,
4521 pAddBssParams->staContext.ch_width,
4522 pAddBssParams->staContext.
4523 vhtTxBFCapable);
4524 } else {
4525 pAddBssParams->staContext.ch_width =
4526 CH_WIDTH_20MHZ;
4527 }
4528 pAddBssParams->staContext.mimoPS =
4529 (tSirMacHTMIMOPowerSaveState) pBeaconStruct->HTCaps.
4530 mimoPowerSave;
4531 pAddBssParams->staContext.maxAmsduSize =
4532 (uint8_t) pBeaconStruct->HTCaps.maximalAMSDUsize;
4533 pAddBssParams->staContext.maxAmpduDensity =
4534 pBeaconStruct->HTCaps.mpduDensity;
4535 pAddBssParams->staContext.fDsssCckMode40Mhz =
4536 (uint8_t) pBeaconStruct->HTCaps.dsssCckMode40MHz;
4537 /*
4538 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
4539 * if they are set then we will use what ever Beacon coming
4540 * from AP supports. If these values are set as 0 in ini file
4541 * then we will hardcode this values to 0.
4542 */
4543 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int
4544 (pMac, WNI_CFG_SHORT_GI_20MHZ,
4545 &shortGi20MhzSupport))) {
4546 if (true == shortGi20MhzSupport)
4547 pAddBssParams->staContext.fShortGI20Mhz =
4548 (uint8_t)pBeaconStruct->HTCaps.shortGI20MHz;
4549 else
4550 pAddBssParams->staContext.fShortGI20Mhz =
4551 false;
4552 } else {
4553 lim_log(pMac, LOGE, FL(
4554 "get shortGI 20Mhz failed, set default"));
4555 pAddBssParams->staContext.fShortGI20Mhz =
4556 WNI_CFG_SHORT_GI_20MHZ_STADEF;
4557 }
4558
4559 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int
4560 (pMac, WNI_CFG_SHORT_GI_40MHZ,
4561 &shortGi40MhzSupport))) {
4562 if (true == shortGi40MhzSupport) {
4563 pAddBssParams->staContext.
4564 fShortGI40Mhz =
4565 (uint8_t) pBeaconStruct->HTCaps.
4566 shortGI40MHz;
4567 } else {
4568 pAddBssParams->staContext.
4569 fShortGI40Mhz = false;
4570 }
4571 } else {
4572 lim_log(pMac, LOGE, FL(
4573 "get shortGI 40Mhz failed, set default"));
4574 pAddBssParams->staContext.fShortGI40Mhz =
4575 WNI_CFG_SHORT_GI_40MHZ_STADEF;
4576 }
4577
4578 pAddBssParams->staContext.maxAmpduSize =
4579 pBeaconStruct->HTCaps.maxRxAMPDUFactor;
4580 if (pAddBssParams->staContext.vhtTxBFCapable
4581 && pMac->lim.disableLDPCWithTxbfAP) {
4582 pAddBssParams->staContext.htLdpcCapable = 0;
4583 pAddBssParams->staContext.vhtLdpcCapable = 0;
4584 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004585 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
4586 pAddBssParams->staContext.htLdpcCapable =
4587 (uint8_t) pBeaconStruct->HTCaps.
4588 advCodingCap;
4589 else
4590 pAddBssParams->staContext.htLdpcCapable = 0;
4591
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 if (pBeaconStruct->VHTCaps.present)
4593 vht_caps = &pBeaconStruct->VHTCaps;
4594 else if (pBeaconStruct->vendor2_ie.VHTCaps.present) {
4595 vht_caps =
4596 &pBeaconStruct->vendor2_ie.VHTCaps;
4597 lim_log(pMac, LOG1, FL(
4598 "VHT Caps are in vendor Specfic IE"));
4599 }
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004600 if (vht_caps != NULL &&
4601 (psessionEntry->txLdpcIniFeatureEnabled & 0x2))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 pAddBssParams->staContext.vhtLdpcCapable =
4603 (uint8_t) vht_caps->ldpcCodingCap;
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004604 else
4605 pAddBssParams->staContext.vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 }
4607
4608 if (pBeaconStruct->HTInfo.present)
4609 pAddBssParams->staContext.rifsMode =
4610 pBeaconStruct->HTInfo.rifsMode;
4611 lim_log(pMac, LOG2,
4612 FL("StaContext ChannelWidth: %d mimoPS: %d maxAmsduSize: %d"),
4613 pAddBssParams->staContext.ch_width,
4614 pAddBssParams->staContext.mimoPS,
4615 pAddBssParams->staContext.maxAmsduSize);
4616
4617 lim_log(pMac, LOG2, FL(
4618 "maxAmpduDensity %d Cck40Mhz %d SGI20Mhz %d"),
4619 pAddBssParams->staContext.maxAmpduDensity,
4620 pAddBssParams->staContext.fDsssCckMode40Mhz,
4621 pAddBssParams->staContext.fShortGI20Mhz);
4622
4623 lim_log(pMac, LOG2, FL(
4624 "SGI40M %d maxAmpdu %d htLdpc %d vhtLdpc %d"),
4625 pAddBssParams->staContext.fShortGI40Mhz,
4626 pAddBssParams->staContext.maxAmpduSize,
4627 pAddBssParams->staContext.htLdpcCapable,
4628 pAddBssParams->staContext.vhtLdpcCapable);
4629 }
4630 /*
4631 * If WMM IE or 802.11E IE is not present
4632 * and AP is HT AP then enable WMM
4633 */
4634 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent ||
4635 pAddBssParams->staContext.htCapable)) ||
4636 (psessionEntry->limQosEnabled &&
4637 (pBeaconStruct->edcaPresent ||
4638 pAddBssParams->staContext.htCapable)))
4639 pAddBssParams->staContext.wmmEnabled = 1;
4640 else
4641 pAddBssParams->staContext.wmmEnabled = 0;
4642
4643 /* Update the rates */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 lim_populate_peer_rate_set(pMac,
4645 &pAddBssParams->staContext.
4646 supportedRates,
4647 pBeaconStruct->HTCaps.supportedMCSSet,
4648 false, psessionEntry,
4649 &pBeaconStruct->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650
4651 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4652
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
4654 lim_log(pMac, LOG2, FL("maxTxPower: %d"), pAddBssParams->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304656 pAddBssParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 pAddBssParams->respReqd = true;
4658
4659 pAddBssParams->staContext.smesessionId = psessionEntry->smeSessionId;
4660 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4661 pAddBssParams->sessionId = psessionEntry->peSessionId;
4662
4663 pAddBssParams->halPersona = (uint8_t) psessionEntry->pePersona; /* update persona */
4664
4665 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
4666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667 pAddBssParams->extSetStaKeyParamValid = 0;
4668 lim_log(pMac, LOG2, FL("extSetStaKeyParamValid: %d"),
4669 pAddBssParams->extSetStaKeyParamValid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670
4671#ifdef WLAN_FEATURE_11W
4672 if (psessionEntry->limRmfEnabled) {
4673 pAddBssParams->rmfEnabled = 1;
4674 pAddBssParams->staContext.rmfEnabled = 1;
4675 }
4676#endif
4677
4678 pAddBssParams->nss = psessionEntry->nss;
4679 lim_log(pMac, LOG2, FL("nss value: %d"), pAddBssParams->nss);
4680
4681 /* Set a new state for MLME */
4682 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4683
4684 MTRACE(mac_trace
4685 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
4686 psessionEntry->limMlmState));
4687
4688 lim_log(pMac, LOG2, FL("staContext wmmEnabled: %d encryptType: %d "
4689 "p2pCapableSta: %d"),
4690 pAddBssParams->staContext.wmmEnabled,
4691 pAddBssParams->staContext.encryptType,
4692 pAddBssParams->staContext.p2pCapableSta);
4693
4694 lim_log(pMac, LOG2, FL("bSpectrumMgtEnabled: %d halPersona: %d setting "
4695 "LimMlm state to %d"),
4696 pAddBssParams->bSpectrumMgtEnabled, pAddBssParams->halPersona,
4697 psessionEntry->limMlmState);
4698
4699 /* we need to defer the message until we get the response back from HAL. */
4700 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4701
4702 msgQ.type = WMA_ADD_BSS_REQ;
4703 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4704 msgQ.reserved = 0;
4705 msgQ.bodyptr = pAddBssParams;
4706 msgQ.bodyval = 0;
4707
4708 lim_log(pMac, LOG1, FL("SessionId:%d Sending WMA_ADD_BSS_REQ"),
4709 psessionEntry->peSessionId);
4710 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
4711
4712 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4713 if (eSIR_SUCCESS != retCode) {
4714 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304715 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 lim_log(pMac, LOGE,
4717 FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
4718 retCode);
4719 goto returnFailure;
4720
4721 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304722 qdf_mem_free(pBeaconStruct);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 return retCode;
4724 }
4725
4726returnFailure:
4727 /* Clean-up will be done by the caller... */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304728 qdf_mem_free(pBeaconStruct);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 return retCode;
4730}
4731
4732/**
4733 * lim_prepare_and_send_del_sta_cnf() - prepares and send del sta cnf
4734 *
4735 * @pMac: mac global context
4736 * @pStaDs: sta dph node
4737 * @statusCode: status code
4738 * @psessionEntry: session context
4739 *
4740 * deletes DPH entry, changes the MLM mode for station, calls
4741 * lim_send_del_sta_cnf
4742 *
4743 * Return: void
4744 */
4745void
4746lim_prepare_and_send_del_sta_cnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
4747 tSirResultCodes statusCode,
4748 tpPESession psessionEntry)
4749{
4750 uint16_t staDsAssocId = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304751 struct qdf_mac_addr sta_dsaddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 tLimMlmStaContext mlmStaContext;
4753
4754 if (pStaDs == NULL) {
4755 PELOGW(lim_log(pMac, LOGW, FL("pStaDs is NULL"));)
4756 return;
4757 }
4758 staDsAssocId = pStaDs->assocId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304759 qdf_mem_copy((uint8_t *) sta_dsaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304760 pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761
4762 mlmStaContext = pStaDs->mlmStaContext;
4763 if (LIM_IS_AP_ROLE(psessionEntry) ||
4764 LIM_IS_BT_AMP_AP_ROLE(psessionEntry)) {
4765 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
4766 }
4767 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr, pStaDs->assocId,
4768 psessionEntry);
4769
4770 if (LIM_IS_STA_ROLE(psessionEntry) ||
4771 LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
4772 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
4773 MTRACE(mac_trace(pMac, TRACE_CODE_MLM_STATE,
4774 psessionEntry->peSessionId,
4775 psessionEntry->limMlmState));
4776 }
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08004777 lim_send_del_sta_cnf(pMac, sta_dsaddr, staDsAssocId, mlmStaContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004778 statusCode, psessionEntry);
4779}
4780
4781/** -------------------------------------------------------------
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 \fn lim_init_pre_auth_timer_table
4783 \brief Initialize the Pre Auth Tanle and creates the timer for
4784 each node for the timeout value got from cfg.
4785 \param tpAniSirGlobal pMac
4786 \param tpLimPreAuthTable pPreAuthTimerTable
4787 \return none
4788 -------------------------------------------------------------*/
4789void lim_init_pre_auth_timer_table(tpAniSirGlobal pMac,
4790 tpLimPreAuthTable pPreAuthTimerTable)
4791{
4792 uint32_t cfgValue;
4793 uint32_t authNodeIdx;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004794 tLimPreAuthNode **pAuthNode = pPreAuthTimerTable->pTable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004795
4796 /* Get AUTH_RSP Timers value */
4797
4798 if (wlan_cfg_get_int(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4799 &cfgValue) != eSIR_SUCCESS) {
4800 /*
4801 ** Could not get AUTH_RSP timeout value
4802 ** from CFG. Log error.
4803 **/
4804 lim_log(pMac, LOGP,
4805 FL("could not retrieve AUTH_RSP timeout value"));
4806 return;
4807 }
4808
4809 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4810 for (authNodeIdx = 0; authNodeIdx < pPreAuthTimerTable->numEntry;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004811 authNodeIdx++) {
4812 if (tx_timer_create(pMac, &(pAuthNode[authNodeIdx]->timer),
Naveen Rawat22b1a932015-08-26 12:13:18 -07004813 "AUTH RESPONSE TIMEOUT",
4814 lim_auth_response_timer_handler, authNodeIdx,
4815 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004816 /* Cannot create timer. Log error. */
4817 lim_log(pMac, LOGP,
4818 FL("Cannot create Auth Rsp timer of Index :%d."),
4819 authNodeIdx);
4820 return;
4821 }
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004822 pAuthNode[authNodeIdx]->authNodeIdx = (uint8_t) authNodeIdx;
4823 pAuthNode[authNodeIdx]->fFree = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825}
4826
4827/** -------------------------------------------------------------
4828 \fn lim_acquire_free_pre_auth_node
4829 \brief Retrives a free Pre Auth node from Pre Auth Table.
4830 \param tpAniSirGlobal pMac
4831 \param tpLimPreAuthTable pPreAuthTimerTable
4832 \return none
4833 -------------------------------------------------------------*/
4834tLimPreAuthNode *lim_acquire_free_pre_auth_node(tpAniSirGlobal pMac,
4835 tpLimPreAuthTable pPreAuthTimerTable)
4836{
4837 uint32_t i;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004838 tLimPreAuthNode **pTempNode = pPreAuthTimerTable->pTable;
4839 for (i = 0; i < pPreAuthTimerTable->numEntry; i++) {
4840 if (pTempNode[i]->fFree == 1) {
4841 pTempNode[i]->fFree = 0;
4842 return pTempNode[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843 }
4844 }
4845
4846 return NULL;
4847}
4848
4849/** -------------------------------------------------------------
4850 \fn lim_get_pre_auth_node_from_index
4851 \brief Depending on the Index this retrives the pre auth node.
4852 \param tpAniSirGlobal pMac
4853 \param tpLimPreAuthTable pAuthTable
4854 \param uint32_t authNodeIdx
4855 \return none
4856 -------------------------------------------------------------*/
4857tLimPreAuthNode *lim_get_pre_auth_node_from_index(tpAniSirGlobal pMac,
4858 tpLimPreAuthTable pAuthTable,
4859 uint32_t authNodeIdx)
4860{
4861 if ((authNodeIdx >= pAuthTable->numEntry)
4862 || (pAuthTable->pTable == NULL)) {
4863 lim_log(pMac, LOGE,
4864 FL("Invalid Auth Timer Index : %d NumEntry : %d"),
4865 authNodeIdx, pAuthTable->numEntry);
4866 return NULL;
4867 }
4868
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004869 return pAuthTable->pTable[authNodeIdx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870}
4871
4872/* Util API to check if the channels supported by STA is within range */
4873tSirRetStatus lim_is_dot11h_supported_channels_valid(tpAniSirGlobal pMac,
4874 tSirAssocReq *assoc)
4875{
4876 /*
4877 * Allow all the stations to join with us.
4878 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4879 * as an input into an algorithm used to select a new channel for the BSS.
4880 * The specification of the algorithm is beyond the scope of this amendment.
4881 */
4882
4883 return eSIR_SUCCESS;
4884}
4885
4886/* Util API to check if the txpower supported by STA is within range */
4887tSirRetStatus lim_is_dot11h_power_capabilities_in_range(tpAniSirGlobal pMac,
4888 tSirAssocReq *assoc,
4889 tpPESession psessionEntry)
4890{
Amar Singhala297bfa2015-10-15 15:07:29 -07004891 int8_t localMaxTxPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 uint32_t localPwrConstraint;
4893
4894 localMaxTxPower =
4895 cfg_get_regulatory_max_transmit_power(pMac,
4896 psessionEntry->currentOperChannel);
4897
4898 if (wlan_cfg_get_int
4899 (pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT,
4900 &localPwrConstraint) != eSIR_SUCCESS) {
4901 lim_log(pMac, LOGP,
4902 FL("Unable to get Local Power Constraint from cfg"));
4903 return eSIR_FAILURE;
4904 }
Amar Singhala297bfa2015-10-15 15:07:29 -07004905 localMaxTxPower -= (int8_t) localPwrConstraint;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906
4907 /**
4908 * The min Tx Power of the associating station should not be greater than (regulatory
4909 * max tx power - local power constraint configured on AP).
4910 */
4911 if (assoc->powerCapability.minTxPower > localMaxTxPower) {
4912 lim_log(pMac, LOGW,
4913 FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d"),
4914 assoc->powerCapability.minTxPower, localMaxTxPower);
4915 return eSIR_FAILURE;
4916 }
4917
4918 return eSIR_SUCCESS;
4919}
4920
4921/** -------------------------------------------------------------
4922 \fn lim_fill_rx_highest_supported_rate
4923 \brief Fills in the Rx Highest Supported Data Rate field from
4924 \ the 'supported MCS set' field in HT capability element.
4925 \param tpAniSirGlobal pMac
4926 \param tpSirSupportedRates pRates
4927 \param uint8_t* pSupportedMCSSet
4928 \return none
4929 -------------------------------------------------------------*/
4930void lim_fill_rx_highest_supported_rate(tpAniSirGlobal pMac,
4931 uint16_t *rxHighestRate,
4932 uint8_t *pSupportedMCSSet)
4933{
4934 tSirMacRxHighestSupportRate *pRxHighestRate;
4935 uint8_t *pBuf;
4936 uint16_t rate = 0;
4937
4938 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4939 rate = lim_get_u16(pBuf);
4940
4941 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4942 *rxHighestRate = pRxHighestRate->rate;
4943
4944 return;
4945}
4946
4947#ifdef WLAN_FEATURE_11W
4948/** -------------------------------------------------------------
4949 \fn lim_send_sme_unprotected_mgmt_frame_ind
4950 \brief Forwards the unprotected management frame to SME.
4951 \param tpAniSirGlobal pMac
4952 \param frameType - 802.11 frame type
4953 \param frame - frame buffer
4954 \param sessionId - id for the current session
4955 \param psessionEntry - PE session context
4956 \return none
4957 -------------------------------------------------------------*/
4958void lim_send_sme_unprotected_mgmt_frame_ind(tpAniSirGlobal pMac, uint8_t frameType,
4959 uint8_t *frame, uint32_t frameLen,
4960 uint16_t sessionId,
4961 tpPESession psessionEntry)
4962{
4963 tSirMsgQ mmhMsg;
4964 tSirSmeUnprotMgmtFrameInd *pSirSmeMgmtFrame = NULL;
4965 uint16_t length;
4966
4967 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4968
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304969 pSirSmeMgmtFrame = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 if (NULL == pSirSmeMgmtFrame) {
4971 lim_log(pMac, LOGP,
4972 FL
4973 ("AllocateMemory failed for tSirSmeUnprotectedMgmtFrameInd"));
4974 return;
4975 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304976 qdf_mem_set((void *)pSirSmeMgmtFrame, length, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977
4978 pSirSmeMgmtFrame->sessionId = sessionId;
4979 pSirSmeMgmtFrame->frameType = frameType;
4980
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304981 qdf_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 pSirSmeMgmtFrame->frameLen = frameLen;
4983
4984 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4985 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4986 mmhMsg.bodyval = 0;
4987
4988 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
4989 return;
4990}
4991#endif
4992
4993#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4994/** -------------------------------------------------------------
4995 \fn lim_send_sme_tsm_ie_ind
4996 \brief Forwards the TSM IE information to SME.
4997 \param tpAniSirGlobal pMac
4998 \param psessionEntry - PE session context
4999 \param tid - traffic id
5000 \param state - tsm state (enabled/disabled)
5001 \param measurementInterval - measurement interval
5002 \return none
5003 -------------------------------------------------------------*/
5004void lim_send_sme_tsm_ie_ind(tpAniSirGlobal pMac, tpPESession psessionEntry,
5005 uint8_t tid, uint8_t state, uint16_t measInterval)
5006{
5007 tSirMsgQ mmhMsg;
5008 tpSirSmeTsmIEInd pSirSmeTsmIeInd = NULL;
5009
5010 if (!pMac || !psessionEntry)
5011 return;
5012
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305013 pSirSmeTsmIeInd = qdf_mem_malloc(sizeof(tSirSmeTsmIEInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 if (NULL == pSirSmeTsmIeInd) {
5015 lim_log(pMac, LOGP,
5016 FL("AllocateMemory failed for tSirSmeTsmIEInd"));
5017 return;
5018 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305019 qdf_mem_set((void *)pSirSmeTsmIeInd, sizeof(tSirSmeTsmIEInd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020
5021 pSirSmeTsmIeInd->sessionId = psessionEntry->smeSessionId;
5022 pSirSmeTsmIeInd->tsmIe.tsid = tid;
5023 pSirSmeTsmIeInd->tsmIe.state = state;
5024 pSirSmeTsmIeInd->tsmIe.msmt_interval = measInterval;
5025
5026 mmhMsg.type = eWNI_SME_TSM_IE_IND;
5027 mmhMsg.bodyptr = pSirSmeTsmIeInd;
5028 mmhMsg.bodyval = 0;
5029
5030 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
5031 return;
5032}
5033#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */