blob: 51698cf7233fefdb7776e595ac375eaf5b147745 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Arif Hussain1513cb22018-01-05 19:56:31 -08002 * Copyright (c) 2011-2018 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"
Naveen Rawat08db88f2017-09-08 15:07:48 -070064#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065
Yingying Tanga1863be2017-03-22 18:10:43 +080066#ifdef FEATURE_WLAN_TDLS
67#define IS_TDLS_PEER(type) ((type) == STA_ENTRY_TDLS_PEER)
68#else
69#define IS_TDLS_PEER(type) 0
70#endif
71
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072/**
Srinivas Girigowdacba74732016-01-14 17:35:25 -080073 * lim_cmp_ssid() - utility function to compare SSIDs
74 * @rx_ssid: Received SSID
75 * @session_entry: Session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077 * This function is called in various places within LIM code
Srinivas Girigowdacba74732016-01-14 17:35:25 -080078 * to determine whether received SSID is same as SSID in use.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 *
Ankit Guptad66a8812016-09-15 11:00:16 -070080 * Return: zero if SSID matched, non-zero otherwise.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053082uint32_t lim_cmp_ssid(tSirMacSSid *rx_ssid, tpPESession session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053084 return qdf_mem_cmp(rx_ssid, &session_entry->ssId,
Srinivas Girigowdacba74732016-01-14 17:35:25 -080085 session_entry->ssId.length);
86}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087
88/**
89 * lim_compare_capabilities()
90 *
91 ***FUNCTION:
92 * This function is called during Association/Reassociation
93 * frame handling to determine whether received capabilities
94 * match with local capabilities or not.
95 *
96 ***LOGIC:
97 *
98 ***ASSUMPTIONS:
99 * NA
100 *
101 ***NOTE:
102 * NA
103 *
104 * @param pMac - Pointer to Global MAC structure
105 * @param pAssocReq - Pointer to received Assoc Req frame
106 * @param pLocalCapabs - Pointer to local capabilities
107 *
108 * @return status - true for Capabilitity match else false.
109 */
110
111uint8_t
112lim_compare_capabilities(tpAniSirGlobal pMac,
113 tSirAssocReq *pAssocReq,
114 tSirMacCapabilityInfo *pLocalCapabs,
115 tpPESession psessionEntry)
116{
117 uint32_t val;
118
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -0700119 if (LIM_IS_AP_ROLE(psessionEntry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120 (pAssocReq->capabilityInfo.ibss)) {
121 /* Requesting STA asserting IBSS capability. */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700122 pe_debug("Requesting STA asserting IBSS capability");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123 return false;
124 }
125 /* Compare CF capabilities */
126 if (pAssocReq->capabilityInfo.cfPollable ||
127 pAssocReq->capabilityInfo.cfPollReq) {
128 /* AP does not support PCF functionality */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700129 pe_debug(" AP does not support PCF functionality");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130 return false;
131 }
132 /* Compare short preamble capability */
133 if (pAssocReq->capabilityInfo.shortPreamble &&
134 (pAssocReq->capabilityInfo.shortPreamble !=
135 pLocalCapabs->shortPreamble)) {
136 /* Allowing a STA requesting short preamble while */
137 /* AP does not support it */
138 }
139
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700140 pe_debug("QoS in AssocReq: %d, local capabs qos: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141 pAssocReq->capabilityInfo.qos, pLocalCapabs->qos);
142
143 /* Compare QoS capability */
144 if (pAssocReq->capabilityInfo.qos &&
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700145 (pAssocReq->capabilityInfo.qos != pLocalCapabs->qos))
146 pe_debug("Received unmatched QOS but cfg to suppress - continuing");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147
148 /*
149 * If AP supports shortSlot and if apple user has
150 * enforced association only from shortSlot station,
151 * then AP must reject any station that does not support
152 * shortSlot
153 */
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -0700154 if (LIM_IS_AP_ROLE(psessionEntry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 (pLocalCapabs->shortSlotTime == 1)) {
156 if (wlan_cfg_get_int
157 (pMac, WNI_CFG_ACCEPT_SHORT_SLOT_ASSOC_ONLY,
158 &val) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700159 pe_err("error getting WNI_CFG_FORCE_SHORT_SLOT_ASSOC_ONLY");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 return false;
161 }
162 if (val) {
163 if (pAssocReq->capabilityInfo.shortSlotTime !=
164 pLocalCapabs->shortSlotTime) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700165 pe_err("AP rejects association as station doesnt support shortslot time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 return false;
167 }
168 return false;
169 }
170 }
171
172 return true;
173} /****** end lim_compare_capabilities() ******/
174
175/**
176 * lim_check_rx_basic_rates()
177 *
178 ***FUNCTION:
179 * This function is called during Association/Reassociation
180 * frame handling to determine whether received rates in
181 * Assoc/Reassoc request frames include all BSS basic rates
182 * or not.
183 *
184 ***LOGIC:
185 *
186 ***ASSUMPTIONS:
187 * NA
188 *
189 ***NOTE:
190 * NA
191 *
192 * @param rxRateSet - pointer to SSID structure
193 *
194 * @return status - true if ALL BSS basic rates are present in the
195 * received rateset else false.
196 */
197
198uint8_t
199lim_check_rx_basic_rates(tpAniSirGlobal pMac, tSirMacRateSet rxRateSet,
200 tpPESession psessionEntry)
201{
202 tSirMacRateSet *pRateSet, basicRate;
203 uint8_t i, j, k, match;
204
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530205 pRateSet = qdf_mem_malloc(sizeof(tSirMacRateSet));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 if (NULL == pRateSet) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700207 pe_err("call to AllocateMemory failed for RATESET");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 return false;
209 }
210
211 /* Copy operational rate set from session Entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530212 qdf_mem_copy(pRateSet->rate, (psessionEntry->rateSet.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 psessionEntry->rateSet.numRates);
214
215 pRateSet->numRates = psessionEntry->rateSet.numRates;
216
217 /* Extract BSS basic rateset from operational rateset */
218 for (i = 0, j = 0;
219 ((i < pRateSet->numRates) && (i < SIR_MAC_RATESET_EID_MAX)); i++) {
220 if ((pRateSet->rate[i] & 0x80) == 0x80) {
221 /* msb is set, so this is a basic rate */
222 basicRate.rate[j++] = pRateSet->rate[i];
223 }
224 }
225
226 /*
227 * For each BSS basic rate, find if it is present in the
228 * received rateset.
229 */
230 for (k = 0; k < j; k++) {
231 match = 0;
232 for (i = 0;
233 ((i < rxRateSet.numRates)
234 && (i < SIR_MAC_RATESET_EID_MAX)); i++) {
235 if ((rxRateSet.rate[i] | 0x80) == basicRate.rate[k])
236 match = 1;
237 }
238
239 if (!match) {
240 /* Free up memory allocated for rateset */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530241 qdf_mem_free((uint8_t *) pRateSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242
243 return false;
244 }
245 }
246
247 /* Free up memory allocated for rateset */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530248 qdf_mem_free((uint8_t *) pRateSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249
250 return true;
251} /****** end lim_check_rx_basic_rates() ******/
252
253/**
254 * lim_check_mcs_set()
255 *
256 ***FUNCTION:
257 * This function is called during Association/Reassociation
258 * frame handling to determine whether received MCS rates in
259 * Assoc/Reassoc request frames includes all Basic MCS Rate Set or not.
260 *
261 ***LOGIC:
262 *
263 ***ASSUMPTIONS:
264 * NA
265 *
266 ***NOTE:
267 * NA
268 *
269 * @param supportedMCSSet - pointer to Supported MCS Rate Set
270 *
271 * @return status - true if ALL MCS Basic Rate Set rates are present in the
272 * received rateset else false.
273 */
274
275uint8_t lim_check_mcs_set(tpAniSirGlobal pMac, uint8_t *supportedMCSSet)
276{
277 uint8_t basicMCSSet[SIZE_OF_BASIC_MCS_SET] = { 0 };
278 uint32_t cfgLen = 0;
279 uint8_t i;
280 uint8_t validBytes;
281 uint8_t lastByteMCSMask = 0x1f;
282
283 cfgLen = WNI_CFG_BASIC_MCS_SET_LEN;
284 if (wlan_cfg_get_str(pMac, WNI_CFG_BASIC_MCS_SET,
285 (uint8_t *) basicMCSSet,
286 (uint32_t *) &cfgLen) != eSIR_SUCCESS) {
287 /* / Could not get Basic MCS rateset from CFG. Log error. */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700288 pe_err("could not retrieve Basic MCS rateset");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 return false;
290 }
291
292 validBytes = VALID_MCS_SIZE / 8;
293
294 /* check if all the Basic MCS Bits are set in supported MCS bitmap */
295 for (i = 0; i < validBytes; i++) {
296 if ((basicMCSSet[i] & supportedMCSSet[i]) != basicMCSSet[i]) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700297 pe_warn("One of Basic MCS Set Rates is not supported by the Station");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 return false;
299 }
300 }
301
302 /* check the last 5 bits of the valid MCS bitmap */
303 if (((basicMCSSet[i] & lastByteMCSMask) &
304 (supportedMCSSet[i] & lastByteMCSMask)) !=
305 (basicMCSSet[i] & lastByteMCSMask)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700306 pe_warn("One of Basic MCS Set Rates is not supported by the Station");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 return false;
308 }
309
310 return true;
311}
312
313#define SECURITY_SUITE_TYPE_MASK 0xFF
314#define SECURITY_SUITE_TYPE_WEP40 0x1
315#define SECURITY_SUITE_TYPE_TKIP 0x2
316#define SECURITY_SUITE_TYPE_CCMP 0x4
317#define SECURITY_SUITE_TYPE_WEP104 0x4
Mukul Sharma05504ac2017-06-08 12:35:53 +0530318#define SECURITY_SUITE_TYPE_GCMP 0x8
319#define SECURITY_SUITE_TYPE_GCMP_256 0x9
320
321/**
322 * is_non_rsn_cipher()- API to check whether cipher suit is rsn or not
323 * @cipher_suite: cipher suit
324 *
325 * Return: True in case non ht cipher else false
326 */
327static inline bool is_non_rsn_cipher(uint8_t cipher_suite)
328{
329 uint8_t cipher_mask;
330
331 cipher_mask = cipher_suite & SECURITY_SUITE_TYPE_MASK;
332 if ((cipher_mask == SECURITY_SUITE_TYPE_CCMP) ||
333 (cipher_mask == SECURITY_SUITE_TYPE_GCMP) ||
334 (cipher_mask == SECURITY_SUITE_TYPE_GCMP_256))
335 return false;
336
337 return true;
338}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339
340/**
341 * lim_check_rx_rsn_ie_match()- validate received rsn ie with supported cipher
342 * suites.
343 * @mac_ctx: pointer to global mac structure
344 * @rx_rsn_ie: received rsn IE
345 * @session_entry: pe session entry
346 * @sta_is_ht: peer station HT capability
347 * @pmf_connection: set to true if this is pmf connection
348 *
349 * This function is called during Association/Reassociation
350 * frame handling to determine whether received RSN in
351 * Assoc/Reassoc request frames include supported cipher suites or not.
352 *
353 * Return: eSIR_SUCCESS if ALL BSS basic rates are present in the
354 * received rateset else failure status.
355 */
356
357uint8_t
358lim_check_rx_rsn_ie_match(tpAniSirGlobal mac_ctx, tDot11fIERSN rx_rsn_ie,
359 tpPESession session_entry, uint8_t sta_is_ht,
360 bool *pmf_connection)
361{
362 tDot11fIERSN *rsn_ie;
363 uint8_t i, j, match, only_non_ht_cipher = 1;
364#ifdef WLAN_FEATURE_11W
365 bool we_are_pmf_capable;
366 bool we_require_pmf;
367 bool they_are_pmf_capable;
368 bool they_require_pmf;
369#endif
370
371 /* RSN IE should be received from PE */
372 rsn_ie = &session_entry->gStartBssRSNIe;
373
374 /* Check groupwise cipher suite */
375 for (i = 0; i < sizeof(rx_rsn_ie.gp_cipher_suite); i++)
376 if (rsn_ie->gp_cipher_suite[i] !=
377 rx_rsn_ie.gp_cipher_suite[i]) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700378 pe_debug("Invalid groupwise cipher suite");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
380 }
381
382 /*
383 * For each Pairwise cipher suite check whether we support
384 * received pairwise
385 */
386 match = 0;
387 for (i = 0; i < rx_rsn_ie.pwise_cipher_suite_count; i++) {
388 for (j = 0; j < rsn_ie->pwise_cipher_suite_count; j++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530389 if (!qdf_mem_cmp(&rx_rsn_ie.pwise_cipher_suites[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 &rsn_ie->pwise_cipher_suites[j],
391 sizeof(rsn_ie->pwise_cipher_suites[j]))) {
392 match = 1;
393 break;
394 }
395 }
396
Mukul Sharma05504ac2017-06-08 12:35:53 +0530397 if (sta_is_ht)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398#ifdef ANI_LITTLE_BYTE_ENDIAN
Mukul Sharma05504ac2017-06-08 12:35:53 +0530399 only_non_ht_cipher = is_non_rsn_cipher(
400 rx_rsn_ie.pwise_cipher_suites[i][3]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401#else
Mukul Sharma05504ac2017-06-08 12:35:53 +0530402 only_non_ht_cipher = is_non_rsn_cipher(
403 rx_rsn_ie.pwise_cipher_suites[i][0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 }
406
407 if ((!match) || ((sta_is_ht) && only_non_ht_cipher)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700408 pe_debug("Invalid pairwise cipher suite");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 return eSIR_MAC_INVALID_PAIRWISE_CIPHER_STATUS;
410 }
411 /*
412 * Check RSN capabilities
413 * Bit 0 of First Byte - PreAuthentication Capability
414 */
415 if (((rx_rsn_ie.RSN_Cap[0] >> 0) & 0x1) == true) {
416 /* this is supported by AP only */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700417 pe_debug("Invalid RSN information element capabilities");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 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)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700431 pe_debug("Association fail, robust management frames policy"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 " violation they_require_pmf =%d"
433 " theyArePMFCapable %d weArePMFCapable %d"
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700434 " weRequirePMF %d theyArePMFCapable %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 they_require_pmf, they_are_pmf_capable,
436 we_are_pmf_capable, we_require_pmf,
437 they_are_pmf_capable);
438 return eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION;
439 }
440
441 if (they_are_pmf_capable && we_are_pmf_capable)
442 *pmf_connection = true;
443
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700444 pe_debug("weAreCapable %d, weRequire %d, theyAreCapable %d,"
445 " theyRequire %d, PMFconnection %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 we_are_pmf_capable, we_require_pmf, they_are_pmf_capable,
447 they_require_pmf, *pmf_connection);
448#endif
449
450 return eSIR_SUCCESS;
451}
452
453/**
454 * lim_check_rx_wpa_ie_match() - to check supported cipher suites
455 *
456 * @mac: pointer to global mac structure
457 * @rx_wpaie: Received WPA IE in (Re)Assco req
458 * @session_entry: pointer to PE session
459 * @sta_is_ht: peer station is HT
460 *
461 * This function is called during Association/Reassociation
462 * frame handling to determine whether received RSN in
463 * Assoc/Reassoc request frames include supported cipher suites or not.
464 *
465 * Return: Success if ALL BSS basic rates are present in the
466 * received rateset else failure status.
467 */
468
469uint8_t
470lim_check_rx_wpa_ie_match(tpAniSirGlobal mac, tDot11fIEWPA rx_wpaie,
471 tpPESession session_entry, uint8_t sta_is_ht)
472{
473 tDot11fIEWPA *wpa_ie;
474 uint8_t i, j, match, only_non_ht_cipher = 1;
475
476 /* WPA IE should be received from PE */
477 wpa_ie = &session_entry->gStartBssWPAIe;
478
479 /* Check groupwise cipher suite */
480 for (i = 0; i < 4; i++) {
481 if (wpa_ie->multicast_cipher[i] != rx_wpaie.multicast_cipher[i]) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700482 pe_debug("Invalid groupwise cipher suite");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
484 }
485 }
486
487 /*
488 * For each Pairwise cipher suite check whether we support
489 * received pairwise
490 */
491 match = 0;
492 for (i = 0; i < rx_wpaie.unicast_cipher_count; i++) {
493 for (j = 0; j < wpa_ie->unicast_cipher_count; j++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530494 if (!qdf_mem_cmp(rx_wpaie.unicast_ciphers[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 wpa_ie->unicast_ciphers[j], 4)) {
496 match = 1;
497 break;
498 }
499 }
500
501 if ((sta_is_ht)
502#ifdef ANI_LITTLE_BYTE_ENDIAN
503 &&
504 ((rx_wpaie.
505 unicast_ciphers[i][3] & SECURITY_SUITE_TYPE_MASK) ==
506 SECURITY_SUITE_TYPE_CCMP))
507#else
508 &&
509 ((rx_wpaie.
510 unicast_ciphers[i][0] & SECURITY_SUITE_TYPE_MASK) ==
511 SECURITY_SUITE_TYPE_CCMP))
512#endif
513 {
514 only_non_ht_cipher = 0;
515 }
516
517 }
518
519 if ((!match) || ((sta_is_ht) && only_non_ht_cipher)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700520 pe_debug("Invalid pairwise cipher suite");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 return eSIR_MAC_CIPHER_SUITE_REJECTED_STATUS;
522 }
523
524 return eSIR_SUCCESS;
525}
526
527/**
528 * lim_cleanup_rx_path()
529 *
530 ***FUNCTION:
531 * This function is called to cleanup STA state at SP & RFP.
532 *
533 ***LOGIC:
534 * To circumvent RFP's handling of dummy packet when it does not
535 * have an incomplete packet for the STA to be deleted, a packet
536 * with 'more framgents' bit set will be queued to RFP's WQ before
537 * queuing 'dummy packet'.
538 * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
539 * (Disassociation frame) and routing flags in BD set to eCPU's
540 * Low Priority WQ.
541 * RFP cleans up its local context for the STA id mentioned in the
542 * BD and then pushes BD to eCPU's low priority WQ.
543 *
544 ***ASSUMPTIONS:
545 * NA
546 *
547 ***NOTE:
548 * NA
549 *
550 * @param pMac Pointer to Global MAC structure
551 * @param pStaDs Pointer to the per STA data structure
552 * initialized by LIM and maintained at DPH
553 *
554 * @return None
555 */
556
557tSirRetStatus
558lim_cleanup_rx_path(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
559 tpPESession psessionEntry)
560{
561 tSirRetStatus retCode = eSIR_SUCCESS;
562
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700563 pe_debug("Cleanup Rx Path for AID: %d"
564 "psessionEntry->limSmeState: %d, mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 pStaDs->assocId, psessionEntry->limSmeState,
566 pStaDs->mlmStaContext.mlmState);
567
568 psessionEntry->isCiscoVendorAP = false;
569
570 if (pMac->lim.gLimAddtsSent) {
571 MTRACE(mac_trace
572 (pMac, TRACE_CODE_TIMER_DEACTIVATE,
573 psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
574 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700575 pe_debug("Reset gLimAddtsSent flag and send addts timeout to SME");
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +0530576 lim_process_sme_addts_rsp_timeout(pMac,
577 pMac->lim.gLimAddtsRspTimerCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 }
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 */
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -0700589 if (LIM_IS_AP_ROLE(psessionEntry)) {
Kai Liuffd2bb72016-09-29 00:08:55 +0800590 lim_del_sta(pMac, pStaDs, false, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 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 */
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800611 if (lim_is_roam_synch_in_progress(psessionEntry))
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800612 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
614
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -0700615 if (LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616 MTRACE(mac_trace
617 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
618 eLIM_MLM_WT_DEL_STA_RSP_STATE));
619 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
620 /* Deactivating probe after heart beat timer */
621 lim_deactivate_and_change_timer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
622 lim_deactivate_and_change_timer(pMac, eLIM_JOIN_FAIL_TIMER);
623 pMac->lim.gLastBeaconDtimCount = 0;
624 pMac->lim.gLastBeaconDtimPeriod = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 }
626#ifdef WLAN_DEBUG
627 /* increment a debug count */
628 pMac->lim.gLimNumRxCleanup++;
629#endif
Abhishek Singh96bda8e2015-12-03 16:45:35 +0530630 /* Do DEL BSS or DEL STA only if ADD BSS was success */
631 if (!psessionEntry->add_bss_failed) {
632 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
633 retCode =
634 lim_del_bss(pMac, pStaDs, psessionEntry->bssIdx,
635 psessionEntry);
636 } else
637 retCode = lim_del_sta(pMac,
638 pStaDs, true, psessionEntry);
639 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640
641 return retCode;
642
643} /*** end lim_cleanup_rx_path() ***/
644
645/**
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800646 * lim_send_del_sta_cnf() - Send Del sta confirmation
647 * @pMac: Pointer to Global MAC structure
648 * @sta_dsaddr: sta ds address
649 * @staDsAssocId: sta ds association id
650 * @mlmStaContext: MLM station context
651 * @statusCode: Status code
652 * @psessionEntry: Session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653 *
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800654 * This function is called to send appropriate CNF message to SME.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 *
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800656 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658void
Anurag Chouhan6d760662016-02-20 16:05:43 +0530659lim_send_del_sta_cnf(tpAniSirGlobal pMac, struct qdf_mac_addr sta_dsaddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 uint16_t staDsAssocId, tLimMlmStaContext mlmStaContext,
661 tSirResultCodes statusCode, tpPESession psessionEntry)
662{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 tLimMlmDisassocCnf mlmDisassocCnf;
664 tLimMlmDeauthCnf mlmDeauthCnf;
665 tLimMlmPurgeStaInd mlmPurgeStaInd;
666
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700667 pe_debug("Sessionid: %d staDsAssocId: %d Trigger: %d statusCode: %d sta_dsaddr: "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668 psessionEntry->peSessionId, staDsAssocId,
669 mlmStaContext.cleanupTrigger, statusCode,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800670 MAC_ADDR_ARRAY(sta_dsaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -0700672 if (LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 /* Set BSSID at CFG to null */
674 tSirMacAddr nullAddr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
675
676 sir_copy_mac_addr(nullAddr, psessionEntry->bssId);
677
678 /* Free up buffer allocated for JoinReq held by */
679 /* MLM state machine */
680 if (psessionEntry->pLimMlmJoinReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530681 qdf_mem_free(psessionEntry->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 psessionEntry->pLimMlmJoinReq = NULL;
683 }
684
685 psessionEntry->limAID = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 }
687
688 if ((mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +0530689 eLIM_HOST_DISASSOC) ||
690 (mlmStaContext.cleanupTrigger ==
691 eLIM_LINK_MONITORING_DISASSOC) ||
692 (mlmStaContext.cleanupTrigger ==
693 eLIM_PROMISCUOUS_MODE_DISASSOC)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694 /**
695 * Host or LMM driven Disassociation.
696 * Issue Disassoc Confirm to SME.
697 */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700698 pe_debug("Lim Posting DISASSOC_CNF to Sme. Trigger: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 mlmStaContext.cleanupTrigger);
700
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530701 qdf_mem_copy((uint8_t *) &mlmDisassocCnf.peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530702 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703 mlmDisassocCnf.resultCode = statusCode;
704 mlmDisassocCnf.disassocTrigger = mlmStaContext.cleanupTrigger;
705 /* Update PE session Id */
706 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
707
708 lim_post_sme_message(pMac,
709 LIM_MLM_DISASSOC_CNF,
710 (uint32_t *) &mlmDisassocCnf);
711 } else if ((mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +0530712 eLIM_HOST_DEAUTH) ||
713 (mlmStaContext.cleanupTrigger ==
714 eLIM_LINK_MONITORING_DEAUTH)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800715 /**
716 * Host or LMM driven Deauthentication.
717 * Issue Deauth Confirm to SME.
718 */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700719 pe_debug("Lim Posting DEAUTH_CNF to Sme. Trigger: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720 mlmStaContext.cleanupTrigger);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530721 qdf_copy_macaddr(&mlmDeauthCnf.peer_macaddr, &sta_dsaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 mlmDeauthCnf.resultCode = statusCode;
723 mlmDeauthCnf.deauthTrigger = mlmStaContext.cleanupTrigger;
724 /* PE session Id */
725 mlmDeauthCnf.sessionId = psessionEntry->peSessionId;
726
727 lim_post_sme_message(pMac,
728 LIM_MLM_DEAUTH_CNF,
729 (uint32_t *) &mlmDeauthCnf);
730 } else if ((mlmStaContext.cleanupTrigger ==
731 eLIM_PEER_ENTITY_DISASSOC) ||
732 (mlmStaContext.cleanupTrigger == eLIM_PEER_ENTITY_DEAUTH)) {
733 /**
734 * Received Disassociation/Deauthentication from peer.
735 * Issue Purge Ind to SME.
736 */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700737 pe_debug("Lim Posting PURGE_STA_IND to Sme. Trigger: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 mlmStaContext.cleanupTrigger);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530739 qdf_mem_copy((uint8_t *) &mlmPurgeStaInd.peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530740 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 mlmPurgeStaInd.reasonCode =
742 (uint8_t) mlmStaContext.disassocReason;
743 mlmPurgeStaInd.aid = staDsAssocId;
744 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
745 mlmPurgeStaInd.sessionId = psessionEntry->peSessionId;
746
747 lim_post_sme_message(pMac,
748 LIM_MLM_PURGE_STA_IND,
749 (uint32_t *) &mlmPurgeStaInd);
750 } else if (mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE) {
751 /* PE setup the peer entry in HW upfront, right after join is completed. */
752 /* If there is a failure during rest of the assoc sequence, this context needs to be cleaned up. */
753 uint8_t smesessionId;
754 uint16_t smetransactionId;
755
756 smesessionId = psessionEntry->smeSessionId;
757 smetransactionId = psessionEntry->transactionId;
758
759 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
760 MTRACE(mac_trace
761 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
762 psessionEntry->limSmeState));
763
764 /* if it is a reassoc failure to join new AP */
765 if ((mlmStaContext.resultCode ==
766 eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE)
767 || (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE)
768 || (mlmStaContext.resultCode ==
769 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700770 pe_debug("Lim Posting eWNI_SME_REASSOC_RSP to SME"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771 "resultCode: %d, statusCode: %d,"
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700772 "sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 mlmStaContext.resultCode,
774 mlmStaContext.protStatusCode,
775 psessionEntry->peSessionId);
776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777 lim_send_sme_join_reassoc_rsp(pMac, eWNI_SME_REASSOC_RSP,
778 mlmStaContext.resultCode,
779 mlmStaContext.protStatusCode,
780 psessionEntry, smesessionId,
781 smetransactionId);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530782 if (mlmStaContext.resultCode != eSIR_SME_SUCCESS) {
783 pe_delete_session(pMac, psessionEntry);
784 psessionEntry = NULL;
785 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530787 qdf_mem_free(psessionEntry->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 psessionEntry->pLimJoinReq = NULL;
789
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700790 pe_debug("Lim Posting eWNI_SME_JOIN_RSP to SME."
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 "resultCode: %d,statusCode: %d,"
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700792 "sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 mlmStaContext.resultCode,
794 mlmStaContext.protStatusCode,
795 psessionEntry->peSessionId);
796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797 lim_send_sme_join_reassoc_rsp(pMac, eWNI_SME_JOIN_RSP,
798 mlmStaContext.resultCode,
799 mlmStaContext.protStatusCode,
800 psessionEntry, smesessionId,
801 smetransactionId);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530802
803 if (mlmStaContext.resultCode != eSIR_SME_SUCCESS) {
804 pe_delete_session(pMac, psessionEntry);
805 psessionEntry = NULL;
806 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 }
808
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700809 } else if (mlmStaContext.cleanupTrigger == eLIM_DUPLICATE_ENTRY) {
810 /**
811 * LIM driven Disassociation.
812 * Issue Disassoc Confirm to SME.
813 */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700814 pe_debug("Lim Posting DISASSOC_CNF to Sme. Trigger: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700815 mlmStaContext.cleanupTrigger);
816
817 qdf_mem_copy((uint8_t *) &mlmDisassocCnf.peerMacAddr,
818 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
819 mlmDisassocCnf.resultCode = statusCode;
820 mlmDisassocCnf.disassocTrigger = eLIM_DUPLICATE_ENTRY;
821 /* Update PE session Id */
822 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
823
824 lim_post_sme_message(pMac,
825 LIM_MLM_DISASSOC_CNF,
826 (uint32_t *) &mlmDisassocCnf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 }
828
829 if (NULL != psessionEntry && !LIM_IS_AP_ROLE(psessionEntry)) {
830 pe_delete_session(pMac, psessionEntry);
831 psessionEntry = NULL;
832 }
833}
834
835/**
836 * lim_reject_association() - function to reject Re/Association Request
837 *
838 * @mac_ctx: pointer to global mac structure
839 * @peer_addr: mac address of the peer
840 * @sub_type: Indicates whether it is Association Request (=0) or
841 * Reassociation Request (=1) frame
842 * @add_pre_auth_context:Indicates whether pre-auth context
843 * to be added for this STA
844 * @auth_type: Indicates auth type to be added
845 * @sta_id: Indicates staId of the STA being rejected
846 * association
847 * @delete_sta: Indicates whether to delete STA context
848 * at Polaris
849 * @result_code: Indicates what reasonCode to be sent in
850 * Re/Assoc response to STA
851 * @session_entry: pointer to PE session
852 *
853 * This function is called whenever Re/Association Request need
854 * to be rejected due to failure in assigning an AID or failure
855 * in adding STA context at Polaris or reject by applications.
856 * Resources allocated if any are freedup and (Re) Association
857 * Response frame is sent to requesting STA. Pre-Auth context
858 * will be added for this STA if it does not exist already
859 *
860 * Return: none
861 */
862
863void
864lim_reject_association(tpAniSirGlobal mac_ctx, tSirMacAddr peer_addr,
865 uint8_t sub_type, uint8_t add_pre_auth_context,
866 tAniAuthType auth_type, uint16_t sta_id,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -0800867 uint8_t delete_sta, enum eSirMacStatusCodes result_code,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 tpPESession session_entry)
869{
870 tpDphHashNode sta_ds;
871
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700872 pe_debug("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,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 session_entry->peSessionId, auth_type, sub_type,
874 add_pre_auth_context, sta_id, delete_sta, result_code,
875 MAC_ADDR_ARRAY(peer_addr));
876
877 if (add_pre_auth_context) {
878 /* Create entry for this STA in pre-auth list */
879 struct tLimPreAuthNode *auth_node;
880
881 auth_node = lim_acquire_free_pre_auth_node(mac_ctx,
882 &mac_ctx->lim.gLimPreAuthTimerTable);
883
884 if (auth_node) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530885 qdf_mem_copy((uint8_t *) auth_node->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 peer_addr, sizeof(tSirMacAddr));
887 auth_node->fTimerStarted = 0;
888 auth_node->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
889 auth_node->authType = (tAniAuthType) auth_type;
Anurag Chouhan210db072016-02-22 18:42:15 +0530890 auth_node->timestamp = qdf_mc_timer_get_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 lim_add_pre_auth_node(mac_ctx, auth_node);
892 }
893 }
894
895 if (delete_sta == false) {
896 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
897 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
898 1, peer_addr, sub_type, 0, session_entry);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700899 pe_warn("received Re/Assoc req when max associated STAs reached from");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 lim_print_mac_addr(mac_ctx, peer_addr, LOGW);
901 lim_send_sme_max_assoc_exceeded_ntf(mac_ctx, peer_addr,
902 session_entry->smeSessionId);
903 return;
904 }
905
906 sta_ds = dph_get_hash_entry(mac_ctx, sta_id,
907 &session_entry->dph.dphHashTable);
908
909 if (sta_ds == NULL) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700910 pe_err("No STA context, yet rejecting Association");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911 return;
912 }
913
914 /*
915 * Polaris has state for this STA.
916 * Trigger cleanup.
917 */
918 sta_ds->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
919
920 /* Receive path cleanup */
921 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
922
923 /*
924 * Send Re/Association Response with
925 * status code to requesting STA.
926 */
927 lim_send_assoc_rsp_mgmt_frame(mac_ctx, result_code, 0, peer_addr,
928 sub_type, 0, session_entry);
929
930 if (session_entry->parsedAssocReq[sta_ds->assocId] != NULL) {
931 uint8_t *assoc_req_frame;
932
933 assoc_req_frame = (uint8_t *)((tpSirAssocReq) (session_entry->
934 parsedAssocReq[sta_ds->assocId]))->assocReqFrame;
935 /*
936 *Assoction confirmation is complete,
937 *free the copy of association request frame.
938 */
939 if (assoc_req_frame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530940 qdf_mem_free(assoc_req_frame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 assoc_req_frame = NULL;
942 }
943
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530944 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
946 }
947}
948
949/**
950 * lim_decide_ap_protection_on_ht20_delete() - function to update protection
951 * parameters.
952 * @mac_ctx: pointer to global mac structure
953 * @sta_ds: station node
954 * @beacon_params: ap beacon parameters
955 * @session_entry: pe session entry
956 *
957 * protection related function while HT20 station is getting deleted.
958 *
959 * Return: none
960 */
961static void
962lim_decide_ap_protection_on_ht20_delete(tpAniSirGlobal mac_ctx,
963 tpDphHashNode sta_ds,
964 tpUpdateBeaconParams beacon_params,
965 tpPESession session_entry)
966{
967 uint32_t i = 0;
968
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700969 pe_debug("(%d) A HT 20 STA is disassociated. Addr is %pM",
970 session_entry->gLimHt20Params.numSta, sta_ds->staAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971
972 if (session_entry->gLimHt20Params.numSta > 0) {
973 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
974 if (!session_entry->protStaCache[i].active)
975 continue;
976
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530977 if (!qdf_mem_cmp(session_entry->protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 sta_ds->staAddr, sizeof(tSirMacAddr))) {
979 session_entry->gLimHt20Params.numSta--;
980 session_entry->protStaCache[i].active =
981 false;
982 break;
983 }
984 }
985 }
986
987 if (session_entry->gLimHt20Params.numSta == 0) {
988 /* disable protection */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700989 pe_debug("No 11B STA exists, PESessionID %d",
990 session_entry->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 lim_enable_ht20_protection(mac_ctx, false, false, beacon_params,
992 session_entry);
993 }
994}
995
996/**
997 * lim_decide_ap_protection_on_delete() - update SAP protection on station
998 * deletion.
999 * @mac_ctx: pointer to global mac structure
1000 * @sta_ds: station node
1001 * @beacon_params: ap beacon parameters
1002 * @session_entry: pe session entry
1003 *
1004 * Decides about protection related settings when a station is getting deleted.
1005 *
1006 * Return: none
1007 */
1008void
1009lim_decide_ap_protection_on_delete(tpAniSirGlobal mac_ctx,
1010 tpDphHashNode sta_ds,
1011 tpUpdateBeaconParams beacon_params,
1012 tpPESession session_entry)
1013{
1014 uint32_t phy_mode;
1015 tHalBitVal erp_enabled = eHAL_CLEAR;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001016 enum band_info rf_band = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017 uint32_t i;
1018
1019 if (NULL == sta_ds)
1020 return;
1021
1022 lim_get_rf_band_new(mac_ctx, &rf_band, session_entry);
1023 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1024 erp_enabled = sta_ds->erpEnabled;
1025
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001026 if ((BAND_5G == rf_band) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 (true == session_entry->htCapability) &&
1028 (session_entry->beaconParams.llaCoexist) &&
1029 (false == sta_ds->mlmStaContext.htCapability)) {
1030 /*
1031 * we are HT. if we are 11A, then protection is not required or
1032 * we are HT and 11A station is leaving.
1033 * protection consideration required.
1034 * HT station leaving ==> this case is commonly handled
1035 * between both the bands below.
1036 */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001037 pe_debug("(%d) A 11A STA is disassociated. Addr is %pM",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 session_entry->gLim11aParams.numSta, sta_ds->staAddr);
1039 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1040 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301041 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 session_entry->protStaCache[i].addr,
1043 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301044 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 session_entry->protStaCache[i].active = false;
1046 break;
1047 }
1048 }
1049
1050 if (session_entry->gLim11aParams.numSta == 0) {
1051 /* disable protection */
1052 lim_update_11a_protection(mac_ctx, false, false,
1053 beacon_params, session_entry);
1054 }
1055 }
1056
1057 /* we are HT or 11G and 11B station is getting deleted */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001058 if ((BAND_2G == rf_band) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 (phy_mode == WNI_CFG_PHY_MODE_11G ||
1060 session_entry->htCapability) &&
1061 (erp_enabled == eHAL_CLEAR)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001062 pe_debug("(%d) A legacy STA is disassociated. Addr is %pM",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 session_entry->gLim11bParams.numSta, sta_ds->staAddr);
1064 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1065 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301066 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 session_entry->protStaCache[i].addr,
1068 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301069 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 session_entry->gLim11bParams.numSta--;
1071 session_entry->protStaCache[i].active =
1072 false;
1073 break;
1074 }
1075 }
1076
1077 if (session_entry->gLim11bParams.numSta == 0) {
1078 /* disable protection */
1079 lim_enable11g_protection(mac_ctx, false, false,
1080 beacon_params, session_entry);
1081 }
1082 }
1083
1084 /*
1085 * we are HT AP and non-11B station is leaving.
1086 * 11g station is leaving
1087 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001088 if ((BAND_2G == rf_band) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 session_entry->htCapability &&
1090 !sta_ds->mlmStaContext.htCapability) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001091 pe_debug("(%d) A 11g STA is disassociated. Addr is %pM",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 session_entry->gLim11bParams.numSta, sta_ds->staAddr);
1093 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1094 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301095 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 session_entry->protStaCache[i].addr,
1097 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301098 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099 session_entry->gLim11gParams.numSta--;
1100 session_entry->protStaCache[i].active = false;
1101 break;
1102 }
1103 }
1104
1105 if (session_entry->gLim11gParams.numSta == 0) {
1106 /* disable protection */
1107 lim_enable_ht_protection_from11g(mac_ctx, false, false,
1108 beacon_params,
1109 session_entry);
1110 }
1111 }
1112
1113 if (!((true == session_entry->htCapability) &&
1114 (true == sta_ds->mlmStaContext.htCapability)))
1115 return;
1116
1117 /*
1118 * Applies to 2.4 as well as 5 GHZ.
1119 * HT non-GF leaving
1120 */
1121 if (!sta_ds->htGreenfield) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001122 pe_debug("(%d) A non-GF STA is disassociated. Addr is %pM",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123 session_entry->gLimNonGfParams.numSta, sta_ds->staAddr);
1124 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1125 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301126 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 session_entry->protStaCache[i].addr,
1128 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301129 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 session_entry->protStaCache[i].active = false;
1131 break;
1132 }
1133 }
1134
1135 if (session_entry->gLimNonGfParams.numSta == 0) {
1136 /* disable protection */
1137 lim_enable_ht_non_gf_protection(mac_ctx, false, false,
1138 beacon_params, session_entry);
1139 }
1140 }
1141
1142 /*
1143 * Applies to 2.4 as well as 5 GHZ.
1144 * HT 20Mhz station leaving
1145 */
1146 if (session_entry->beaconParams.ht20Coexist &&
1147 (eHT_CHANNEL_WIDTH_20MHZ ==
1148 sta_ds->htSupportedChannelWidthSet)) {
1149 lim_decide_ap_protection_on_ht20_delete(mac_ctx, sta_ds,
1150 beacon_params, session_entry);
1151 }
1152
1153 /*
1154 * Applies to 2.4 as well as 5 GHZ.
1155 * LSIG TXOP not supporting staiton leaving
1156 */
1157 if ((false == session_entry->beaconParams.
1158 fLsigTXOPProtectionFullSupport) &&
1159 (false == sta_ds->htLsigTXOPProtection)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001160 pe_debug("(%d) A HT LSIG not supporting STA is disassociated. Addr is %pM",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161 session_entry->gLimLsigTxopParams.numSta,
1162 sta_ds->staAddr);
1163 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1164 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 session_entry->protStaCache[i].addr,
1167 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301168 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 session_entry->protStaCache[i].active = false;
1170 break;
1171 }
1172 }
1173
1174 if (session_entry->gLimLsigTxopParams.numSta == 0) {
1175 /* disable protection */
1176 lim_enable_ht_lsig_txop_protection(mac_ctx, true,
1177 false, beacon_params, session_entry);
1178 }
1179 }
1180}
1181
1182/**
1183 * lim_decide_short_preamble() - update short preamble parameters
1184 * @mac_ctx: pointer to global mac structure
1185 * @sta_ds: station node
1186 * @beacon_params: ap beacon parameters
1187 * @session_entry: pe session entry
1188 *
1189 * Decides about any short preamble related change because of new station
1190 * joining.
1191 *
1192 * Return: None
1193 */
Jeff Johnson72c8e7c2016-10-06 18:43:52 -07001194static void lim_decide_short_preamble(tpAniSirGlobal mac_ctx,
1195 tpDphHashNode sta_ds,
1196 tpUpdateBeaconParams beacon_params,
1197 tpPESession session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198{
1199 uint32_t i;
1200
1201 if (sta_ds->shortPreambleEnabled == eHAL_CLEAR) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001202 pe_debug("(%d) A non-short preamble STA is disassociated. Addr is %pM",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 session_entry->gLimNoShortParams.numNonShortPreambleSta,
1204 sta_ds->staAddr);
1205 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1206 if (session_entry->gLimNoShortParams.
1207 staNoShortCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301208 (!qdf_mem_cmp(session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 gLimNoShortParams.
1210 staNoShortCache[i].addr,
1211 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301212 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213 session_entry->gLimNoShortParams.
1214 numNonShortPreambleSta--;
1215 session_entry->gLimNoShortParams.
1216 staNoShortCache[i].active = false;
1217 break;
1218 }
1219 }
1220
1221 if (session_entry->gLimNoShortParams.numNonShortPreambleSta)
1222 return;
1223
1224 /*
1225 * enable short preamble
1226 * reset the cache
1227 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301228 qdf_mem_set((uint8_t *) &session_entry->gLimNoShortParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 sizeof(tLimNoShortParams), 0);
1230 if (lim_enable_short_preamble(mac_ctx, true,
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001231 beacon_params, session_entry) != eSIR_SUCCESS)
1232 pe_err("Cannot enable short preamble");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 }
1234}
1235
1236/**
1237 * lim_decide_short_slot() - update short slot time related parameters
1238 * @mac_ctx: pointer to global mac structure
1239 * @sta_ds: station node
1240 * @beacon_params: ap beacon parameters
1241 * @session_entry: pe session entry
1242 *
1243 * Decides about any short slot time related change because of station leaving
1244 * the BSS.
1245 * Return: None
1246 */
Jeff Johnson72c8e7c2016-10-06 18:43:52 -07001247static void
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248lim_decide_short_slot(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds,
1249 tpUpdateBeaconParams beacon_params,
1250 tpPESession session_entry)
1251{
1252 uint32_t i, val, non_short_slot_sta_count;
1253
1254 if (sta_ds->shortSlotTimeEnabled != eHAL_CLEAR)
1255 return;
1256
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001257 pe_debug("(%d) A non-short slottime STA is disassociated. Addr is %pM",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta,
1259 sta_ds->staAddr);
1260
1261 wlan_cfg_get_int(mac_ctx, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED,
1262 &val);
1263
1264 if (LIM_IS_AP_ROLE(session_entry)) {
1265 non_short_slot_sta_count =
1266 session_entry->gLimNoShortSlotParams.numNonShortSlotSta;
1267 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1268 if (session_entry->gLimNoShortSlotParams.
1269 staNoShortSlotCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301270 (!qdf_mem_cmp(session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 gLimNoShortSlotParams.
1272 staNoShortSlotCache[i].addr,
1273 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301274 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 non_short_slot_sta_count--;
1276 session_entry->gLimNoShortSlotParams.
1277 staNoShortSlotCache[i].active = false;
1278 break;
1279 }
1280 }
1281
1282 if (non_short_slot_sta_count == 0 && val) {
1283 /*
1284 * enable short slot time
1285 * reset the cache
1286 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 qdf_mem_set((uint8_t *) &session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 gLimNoShortSlotParams,
1289 sizeof(tLimNoShortSlotParams), 0);
1290 beacon_params->fShortSlotTime = true;
1291 beacon_params->paramChangeBitmap |=
1292 PARAM_SHORT_SLOT_TIME_CHANGED;
1293 session_entry->shortSlotTimeSupported = true;
1294 }
1295 session_entry->gLimNoShortSlotParams.numNonShortSlotSta =
1296 non_short_slot_sta_count;
1297 } else {
1298 non_short_slot_sta_count =
1299 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta;
1300 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1301 if (mac_ctx->lim.gLimNoShortSlotParams.
1302 staNoShortSlotCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301303 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 mac_ctx->lim.gLimNoShortSlotParams.
1305 staNoShortSlotCache[i].addr,
1306 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301307 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 non_short_slot_sta_count--;
1309 mac_ctx->lim.gLimNoShortSlotParams.
1310 staNoShortSlotCache[i].active = false;
1311 break;
1312 }
1313 }
1314
1315 if (val && !non_short_slot_sta_count) {
1316 /*
1317 * enable short slot time
1318 * reset the cache
1319 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301320 qdf_mem_set(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 (uint8_t *) &mac_ctx->lim.gLimNoShortSlotParams,
1322 sizeof(tLimNoShortSlotParams), 0);
1323 /*in case of AP set SHORT_SLOT_TIME to enable*/
1324 if (LIM_IS_AP_ROLE(session_entry)) {
1325 beacon_params->fShortSlotTime = true;
1326 beacon_params->paramChangeBitmap |=
1327 PARAM_SHORT_SLOT_TIME_CHANGED;
1328 session_entry->shortSlotTimeSupported = true;
1329 }
1330 }
1331 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta =
1332 non_short_slot_sta_count;
1333 }
1334}
1335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336/**
1337 * lim_populate_vht_mcs_set - function to populate vht mcs rate set
1338 * @mac_ctx: pointer to global mac structure
1339 * @rates: pointer to supported rate set
1340 * @peer_vht_caps: pointer to peer vht capabilities
1341 * @session_entry: pe session entry
1342 *
1343 * Populates vht mcs rate set based on peer and self capabilities
1344 *
1345 * Return: eSIR_SUCCESS on success else eSIR_FAILURE
1346 */
1347tSirRetStatus lim_populate_vht_mcs_set(tpAniSirGlobal mac_ctx,
1348 tpSirSupportedRates rates,
1349 tDot11fIEVHTCaps *peer_vht_caps,
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001350 tpPESession session_entry,
1351 uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352{
1353 uint32_t val;
1354 uint32_t self_sta_dot11mode = 0;
1355 uint16_t mcs_map_mask = MCSMAPMASK1x1;
1356 uint16_t mcs_map_mask2x2 = 0;
1357
1358 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_sta_dot11mode);
1359
1360 if (!IS_DOT11_MODE_VHT(self_sta_dot11mode))
1361 return eSIR_SUCCESS;
1362
1363 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RX_MCS_MAP, &val) !=
1364 eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001365 pe_err("could not retrieve VHT RX MCS MAP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 goto error;
1367 }
1368 rates->vhtRxMCSMap = (uint16_t) val;
1369
1370 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TX_MCS_MAP, &val) !=
1371 eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001372 pe_err("could not retrieve VHT TX MCS MAP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 goto error;
1374 }
1375 rates->vhtTxMCSMap = (uint16_t) val;
1376
1377 if (wlan_cfg_get_int(mac_ctx,
1378 WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,
1379 &val) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001380 pe_err("couldn't retrieve VHT RX Supported data rate MAP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 goto error;
1382 }
1383 rates->vhtRxHighestDataRate = (uint16_t) val;
1384
1385 if (wlan_cfg_get_int(mac_ctx,
1386 WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,
1387 &val) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001388 pe_err("couldn't retrieve VHT RX Supported data rate MAP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 goto error;
1390 }
1391 rates->vhtTxHighestDataRate = (uint16_t) val;
1392
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001393 if (NSS_1x1_MODE == nss) {
1394 rates->vhtRxMCSMap |= VHT_MCS_1x1;
1395 rates->vhtTxMCSMap |= VHT_MCS_1x1;
1396 rates->vhtTxHighestDataRate =
1397 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
1398 rates->vhtRxHighestDataRate =
1399 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
Kiran Kumar Lokere0e255172018-03-30 18:54:25 -07001400 if (!session_entry->ch_width &&
1401 !mac_ctx->roam.configParam.enable_vht20_mcs9 &&
1402 ((rates->vhtRxMCSMap & VHT_1x1_MCS_MASK) ==
1403 VHT_1x1_MCS9_MAP)) {
1404 DISABLE_VHT_MCS_9(rates->vhtRxMCSMap,
1405 NSS_1x1_MODE);
1406 DISABLE_VHT_MCS_9(rates->vhtTxMCSMap,
1407 NSS_1x1_MODE);
1408 }
1409 } else {
1410 if (!session_entry->ch_width &&
1411 !mac_ctx->roam.configParam.enable_vht20_mcs9 &&
1412 ((rates->vhtRxMCSMap & VHT_2x2_MCS_MASK) ==
1413 VHT_2x2_MCS9_MAP)) {
1414 DISABLE_VHT_MCS_9(rates->vhtRxMCSMap,
1415 NSS_2x2_MODE);
1416 DISABLE_VHT_MCS_9(rates->vhtTxMCSMap,
1417 NSS_2x2_MODE);
1418 }
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001419 }
1420
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001421 if ((peer_vht_caps == NULL) || (!peer_vht_caps->present))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 return eSIR_SUCCESS;
1423
1424 rates->vhtTxHighestDataRate =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301425 QDF_MIN(rates->vhtTxHighestDataRate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 peer_vht_caps->txSupDataRate);
1427 rates->vhtRxHighestDataRate =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301428 QDF_MIN(rates->vhtRxHighestDataRate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 peer_vht_caps->rxHighSupDataRate);
1430
Abhishek Singhb01ac952017-08-17 13:52:23 +05301431 if (session_entry && session_entry->nss == NSS_2x2_MODE)
1432 mcs_map_mask2x2 = MCSMAPMASK2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433
1434 if ((peer_vht_caps->txMCSMap & mcs_map_mask) <
1435 (rates->vhtRxMCSMap & mcs_map_mask)) {
1436 rates->vhtRxMCSMap &= ~(mcs_map_mask);
1437 rates->vhtRxMCSMap |=
1438 (peer_vht_caps->txMCSMap & mcs_map_mask);
1439 }
1440 if ((peer_vht_caps->rxMCSMap & mcs_map_mask) <
1441 (rates->vhtTxMCSMap & mcs_map_mask)) {
1442 rates->vhtTxMCSMap &= ~(mcs_map_mask);
1443 rates->vhtTxMCSMap |=
1444 (peer_vht_caps->rxMCSMap & mcs_map_mask);
1445 }
1446
1447 if (mcs_map_mask2x2) {
1448
1449 uint16_t peer_mcs_map, self_mcs_map;
1450
1451 peer_mcs_map =
1452 peer_vht_caps->txMCSMap & mcs_map_mask2x2;
1453 self_mcs_map =
1454 rates->vhtRxMCSMap & mcs_map_mask2x2;
1455
1456 if ((self_mcs_map != mcs_map_mask2x2) &&
1457 ((peer_mcs_map == mcs_map_mask2x2) ||
1458 (peer_mcs_map < self_mcs_map))) {
1459 rates->vhtRxMCSMap &= ~mcs_map_mask2x2;
1460 rates->vhtRxMCSMap |= peer_mcs_map;
1461 }
1462
1463 peer_mcs_map =
1464 (peer_vht_caps->rxMCSMap & mcs_map_mask2x2);
1465 self_mcs_map =
1466 (rates->vhtTxMCSMap & mcs_map_mask2x2);
1467
1468 if ((self_mcs_map != mcs_map_mask2x2) &&
1469 ((peer_mcs_map == mcs_map_mask2x2) ||
1470 (peer_mcs_map < self_mcs_map))) {
1471 rates->vhtTxMCSMap &= ~mcs_map_mask2x2;
1472 rates->vhtTxMCSMap |= peer_mcs_map;
1473 }
1474 }
1475
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001476 pe_debug("enable2x2 - %d nss %d vhtRxMCSMap - %x vhtTxMCSMap - %x",
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001477 mac_ctx->roam.configParam.enable2x2, nss,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 rates->vhtRxMCSMap, rates->vhtTxMCSMap);
1479
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001480 if (NULL != session_entry) {
1481 session_entry->supported_nss_1x1 =
1482 ((rates->vhtTxMCSMap & VHT_MCS_1x1) ==
1483 VHT_MCS_1x1) ? true : false;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001484 pe_debug("VHT supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001485 session_entry->supported_nss_1x1);
1486 }
1487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 return eSIR_SUCCESS;
1489error:
1490
1491 return eSIR_FAILURE;
1492}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493
1494/**
1495 * lim_populate_own_rate_set() - comprises the basic and extended rates read
1496 * from CFG
1497 * @mac_ctx: pointer to global mac structure
1498 * @rates: pointer to supported rates
1499 * @supported_mcs_set: pointer to supported mcs rates
1500 * @basic_only: update only basic rates if set true
1501 * @session_entry: pe session entry
1502 * @vht_caps: pointer to vht capability
1503 *
1504 * This function is called by limProcessAssocRsp() or
1505 * lim_add_staInIBSS()
1506 * - It creates a combined rate set of 12 rates max which
1507 * comprises the basic and extended rates read from CFG
1508 * - It sorts the combined rate Set and copy it in the
1509 * rate array of the pSTA descriptor
1510 * - It sets the erpEnabled bit of the STA descriptor
1511 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1512 * an A rate in the supported or extended rate sets
1513 *
1514 * Return: eSIR_SUCCESS or eSIR_FAILURE.
1515 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516tSirRetStatus
1517lim_populate_own_rate_set(tpAniSirGlobal mac_ctx,
1518 tpSirSupportedRates rates, uint8_t *supported_mcs_set,
1519 uint8_t basic_only, tpPESession session_entry,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001520 struct sDot11fIEVHTCaps *vht_caps,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001521 struct sDot11fIEhe_cap *he_caps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522{
1523 tSirMacRateSet temp_rate_set;
1524 tSirMacRateSet temp_rate_set2;
1525 uint32_t i, j, val, min, is_arate;
1526 uint32_t phy_mode = 0;
1527 uint32_t self_sta_dot11mode = 0;
1528 uint8_t a_rate_index = 0;
1529 uint8_t b_rate_index = 0;
1530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 is_arate = 0;
1532
1533 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_sta_dot11mode);
1534 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1535
1536 /*
1537 * Include 11b rates only when the device configured in
1538 * auto, 11a/b/g or 11b_only
1539 */
1540 if ((self_sta_dot11mode == WNI_CFG_DOT11_MODE_ALL) ||
1541 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1542 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11AC) ||
1543 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11N) ||
1544 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1545 (self_sta_dot11mode == WNI_CFG_DOT11_MODE_11B)) {
1546 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1547 wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_RATES_11B,
1548 (uint8_t *) &temp_rate_set.rate, &val);
1549 temp_rate_set.numRates = (uint8_t) val;
1550 } else {
1551 temp_rate_set.numRates = 0;
1552 }
1553
1554 /* Include 11a rates when the device configured in non-11b mode */
1555 if (!IS_DOT11_MODE_11B(self_sta_dot11mode)) {
1556 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1557 wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_RATES_11A,
1558 (uint8_t *) &temp_rate_set2.rate, &val);
1559 temp_rate_set2.numRates = (uint8_t) val;
1560 } else {
1561 temp_rate_set2.numRates = 0;
1562 }
1563
1564 if ((temp_rate_set.numRates + temp_rate_set2.numRates) > 12) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001565 pe_err("more than 12 rates in CFG");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001566 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 }
1568 /* copy all rates in temp_rate_set, there are 12 rates max */
1569 for (i = 0; i < temp_rate_set2.numRates; i++)
1570 temp_rate_set.rate[i + temp_rate_set.numRates] =
1571 temp_rate_set2.rate[i];
1572
1573 temp_rate_set.numRates += temp_rate_set2.numRates;
1574
1575 /**
1576 * Sort rates in temp_rate_set (they are likely to be already sorted)
1577 * put the result in pSupportedRates
1578 */
1579
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301580 qdf_mem_set((uint8_t *) rates, sizeof(tSirSupportedRates), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 for (i = 0; i < temp_rate_set.numRates; i++) {
1582 min = 0;
1583 val = 0xff;
1584 is_arate = 0;
1585
1586 for (j = 0; (j < temp_rate_set.numRates) &&
1587 (j < SIR_MAC_RATESET_EID_MAX); j++) {
1588 if ((uint32_t) (temp_rate_set.rate[j] & 0x7f) <
1589 val) {
1590 val = temp_rate_set.rate[j] & 0x7f;
1591 min = j;
1592 }
1593 }
1594
1595 if (sirIsArate(temp_rate_set.rate[min] & 0x7f))
1596 is_arate = 1;
1597
1598 /*
1599 * HAL needs to know whether the rate is basic rate or
1600 * not, as it needs to update the response rate table
1601 * accordingly. e.g. if one of the 11a rates is
1602 * basic rate, then that rate can be used for sending
1603 * control frames.
1604 * HAL updates the response rate table whenever basic
1605 * rate set is changed.
1606 */
1607 if (basic_only && temp_rate_set.rate[min] & 0x80) {
1608 if (is_arate)
1609 rates->llaRates[a_rate_index++] =
1610 temp_rate_set.rate[min];
1611 else
1612 rates->llbRates[b_rate_index++] =
1613 temp_rate_set.rate[min];
1614 } else {
1615 if (is_arate)
1616 rates->llaRates[a_rate_index++] =
1617 temp_rate_set.rate[min];
1618 else
1619 rates->llbRates[b_rate_index++] =
1620 temp_rate_set.rate[min];
1621 }
1622 temp_rate_set.rate[min] = 0xff;
1623 }
1624
1625 if (IS_DOT11_MODE_HT(self_sta_dot11mode)) {
1626 val = SIZE_OF_SUPPORTED_MCS_SET;
1627 if (wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_MCS_SET,
1628 rates->supportedMCSSet,
1629 &val) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001630 pe_err("could not retrieve supportedMCSSet");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001631 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 }
1633
Arif Hussain74fc5712016-07-20 11:10:01 -07001634 if (session_entry->nss == NSS_1x1_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001635 rates->supportedMCSSet[1] = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 /*
1637 * if supported MCS Set of the peer is passed in,
1638 * then do the intersection
1639 * else use the MCS set from local CFG.
1640 */
1641
1642 if (supported_mcs_set != NULL) {
1643 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1644 rates->supportedMCSSet[i] &=
1645 supported_mcs_set[i];
1646 }
1647
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001648 pe_debug("MCS Rate Set Bitmap: ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001650 pe_debug("%x ", rates->supportedMCSSet[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 }
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001652 lim_populate_vht_mcs_set(mac_ctx, rates, vht_caps,
Arif Hussain74fc5712016-07-20 11:10:01 -07001653 session_entry, session_entry->nss);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001654 lim_populate_he_mcs_set(mac_ctx, rates, he_caps,
1655 session_entry, session_entry->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656
1657 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658}
1659
Naveen Rawatcbcc6542017-10-30 17:55:03 -07001660#ifdef WLAN_FEATURE_11AX
1661/**
1662 * lim_calculate_he_nss() - function to calculate new nss from he rates
1663 * @rates: supported rtes struct object
1664 * @session: pe session entry
1665 * This function calculates nss from rx_he_mcs_map_lt_80 within rates struct
1666 * object and assigns new value to nss within pe_session
1667 *
1668 * Return: None
1669 */
1670static void lim_calculate_he_nss(tpSirSupportedRates rates, tpPESession session)
1671{
1672 HE_GET_NSS(rates->rx_he_mcs_map_lt_80, session->nss);
1673}
1674#else
1675static void lim_calculate_he_nss(tpSirSupportedRates rates, tpPESession session)
1676{
1677}
1678#endif
1679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680tSirRetStatus
1681lim_populate_peer_rate_set(tpAniSirGlobal pMac,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001682 tpSirSupportedRates pRates, uint8_t *pSupportedMCSSet,
1683 uint8_t basicOnly, tpPESession psessionEntry,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001684 tDot11fIEVHTCaps *pVHTCaps, tDot11fIEhe_cap *he_caps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685{
1686 tSirMacRateSet tempRateSet;
1687 tSirMacRateSet tempRateSet2;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001688 uint32_t i, j, val, min, isArate = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689
1690 /* copy operational rate set from psessionEntry */
1691 if (psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301692 qdf_mem_copy((uint8_t *) tempRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 (uint8_t *) (psessionEntry->rateSet.rate),
1694 psessionEntry->rateSet.numRates);
1695 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1696 } else {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001697 pe_err("more than SIR_MAC_RATESET_EID_MAX rates");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001698 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 }
1700 if ((psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
1701 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11A) ||
1702 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11AC) ||
1703 (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11N)) {
1704 if (psessionEntry->extRateSet.numRates <=
1705 SIR_MAC_RATESET_EID_MAX) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301706 qdf_mem_copy((uint8_t *) tempRateSet2.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 (uint8_t *) (psessionEntry->extRateSet.
1708 rate),
1709 psessionEntry->extRateSet.numRates);
1710 tempRateSet2.numRates =
1711 psessionEntry->extRateSet.numRates;
1712 } else {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001713 pe_err("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001714 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 }
1716 } else
1717 tempRateSet2.numRates = 0;
1718 if ((tempRateSet.numRates + tempRateSet2.numRates) >
1719 SIR_MAC_RATESET_EID_MAX) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001720 pe_err("more than 12 rates in CFG");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001721 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 }
1723
1724 /* copy all rates in tempRateSet, there are 12 rates max */
1725 for (i = 0; i < tempRateSet2.numRates; i++)
1726 tempRateSet.rate[i + tempRateSet.numRates] =
1727 tempRateSet2.rate[i];
1728 tempRateSet.numRates += tempRateSet2.numRates;
1729 /**
1730 * Sort rates in tempRateSet (they are likely to be already sorted)
1731 * put the result in pSupportedRates
1732 */
1733 {
1734 uint8_t aRateIndex = 0;
1735 uint8_t bRateIndex = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001736
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301737 qdf_mem_set((uint8_t *) pRates, sizeof(tSirSupportedRates), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 for (i = 0; i < tempRateSet.numRates; i++) {
1739 min = 0;
1740 val = 0xff;
1741 isArate = 0;
1742 for (j = 0;
1743 (j < tempRateSet.numRates)
1744 && (j < SIR_MAC_RATESET_EID_MAX); j++) {
1745 if ((uint32_t) (tempRateSet.rate[j] & 0x7f) <
1746 val) {
1747 val = tempRateSet.rate[j] & 0x7f;
1748 min = j;
1749 }
1750 }
1751 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1752 isArate = 1;
1753 /*
1754 * HAL needs to know whether the rate is basic rate or not, as it needs to
1755 * update the response rate table accordingly. e.g. if one of the 11a rates is
1756 * basic rate, then that rate can be used for sending control frames.
1757 * HAL updates the response rate table whenever basic rate set is changed.
1758 */
1759 if (basicOnly) {
1760 if (tempRateSet.rate[min] & 0x80) {
1761 if (isArate)
1762 pRates->llaRates[aRateIndex++] =
1763 tempRateSet.rate[min];
1764 else
1765 pRates->llbRates[bRateIndex++] =
1766 tempRateSet.rate[min];
1767 }
1768 } else {
1769 if (isArate)
1770 pRates->llaRates[aRateIndex++] =
1771 tempRateSet.rate[min];
1772 else
1773 pRates->llbRates[bRateIndex++] =
1774 tempRateSet.rate[min];
1775 }
1776 tempRateSet.rate[min] = 0xff;
1777 }
1778 }
1779
1780 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)) {
1781 val = SIZE_OF_SUPPORTED_MCS_SET;
1782 if (wlan_cfg_get_str(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1783 pRates->supportedMCSSet,
1784 &val) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001785 pe_err("could not retrieve supportedMCSSet");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001786 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 }
Arif Hussain74fc5712016-07-20 11:10:01 -07001788 if (psessionEntry->nss == NSS_1x1_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001789 pRates->supportedMCSSet[1] = 0;
1790
1791 /* if supported MCS Set of the peer is passed in, then do the
1792 * intersection, else use the MCS set from local CFG.
1793 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 if (pSupportedMCSSet != NULL) {
1795 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1796 pRates->supportedMCSSet[i] &=
1797 pSupportedMCSSet[i];
1798 }
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001799 pe_debug("MCS Rate Set Bitmap: ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001801 pe_debug("%x ", pRates->supportedMCSSet[i]);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001802
Naveen Rawat64176682017-06-14 14:28:37 -07001803 if (pRates->supportedMCSSet[0] == 0) {
1804 pe_debug("Incorrect MCS 0 - 7. They must be supported");
1805 pRates->supportedMCSSet[0] = 0xFF;
1806 }
1807
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001808 psessionEntry->supported_nss_1x1 =
1809 ((pRates->supportedMCSSet[1] != 0) ? false : true);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001810 pe_debug("HT supported nss 1x1: %d",
Archana Ramachandranef777d42016-03-29 16:27:42 -07001811 psessionEntry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 }
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001813 lim_populate_vht_mcs_set(pMac, pRates, pVHTCaps,
Arif Hussain74fc5712016-07-20 11:10:01 -07001814 psessionEntry, psessionEntry->nss);
Naveen Rawat746a90b2017-06-07 15:16:35 -07001815
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001816 lim_populate_he_mcs_set(pMac, pRates, he_caps,
1817 psessionEntry, psessionEntry->nss);
1818
Varun Reddy Yeturu51094862017-08-25 14:27:15 -07001819 if (IS_DOT11_MODE_HE(psessionEntry->dot11mode) && he_caps) {
Naveen Rawatcbcc6542017-10-30 17:55:03 -07001820 lim_calculate_he_nss(pRates, psessionEntry);
Naveen Rawat746a90b2017-06-07 15:16:35 -07001821 } else if (IS_DOT11_MODE_VHT(psessionEntry->dot11mode)) {
1822 if ((pRates->vhtRxMCSMap & MCSMAPMASK2x2) == MCSMAPMASK2x2)
1823 psessionEntry->nss = NSS_1x1_MODE;
1824 } else if (pRates->supportedMCSSet[1] == 0) {
1825 psessionEntry->nss = NSS_1x1_MODE;
1826 }
Varun Reddy Yeturu51094862017-08-25 14:27:15 -07001827 pe_debug("nss: %d", psessionEntry->nss);
Naveen Rawat746a90b2017-06-07 15:16:35 -07001828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830} /*** lim_populate_peer_rate_set() ***/
1831
1832/**
1833 * lim_populate_matching_rate_set() -process the CFG rate sets and
1834 * the rate sets received in the Assoc request on AP.
1835 * @mac_ctx: pointer to global mac structure
1836 * @sta_ds: station node
1837 * @oper_rate_set: pointer to operating rate set
1838 * @ext_rate_set: pointer to extended rate set
1839 * @supported_mcs_set: pointer to supported rate set
1840 * @session_entry: pointer to pe session entry
1841 * @vht_caps: pointer to vht capabilities
1842 *
1843 * This is called at the time of Association Request
1844 * processing on AP and while adding peer's context
1845 * in IBSS role to process the CFG rate sets and
1846 * the rate sets received in the Assoc request on AP
1847 * or Beacon/Probe Response from peer in IBSS.
1848 *
1849 * 1. It makes the intersection between our own rate Sat
1850 * and extemcded rate set and the ones received in the
1851 * association request.
1852 * 2. It creates a combined rate set of 12 rates max which
1853 * comprised the basic and extended rates
1854 * 3. It sorts the combined rate Set and copy it in the
1855 * rate array of the pSTA descriptor
1856 *
1857 * The parser has already ensured unicity of the rates in the
1858 * association request structure
1859 *
1860 * Return: eSIR_SUCCESS on success else eSIR_FAILURE
1861 */
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001862tSirRetStatus lim_populate_matching_rate_set(tpAniSirGlobal mac_ctx,
1863 tpDphHashNode sta_ds,
1864 tSirMacRateSet *oper_rate_set,
1865 tSirMacRateSet *ext_rate_set,
1866 uint8_t *supported_mcs_set,
1867 tpPESession session_entry,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001868 tDot11fIEVHTCaps *vht_caps,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001869 tDot11fIEhe_cap *he_caps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870{
1871 tSirMacRateSet temp_rate_set;
1872 tSirMacRateSet temp_rate_set2;
1873 uint32_t i, j, val, min, is_arate;
1874 uint32_t phy_mode;
1875 uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET];
1876 tpSirSupportedRates rates;
1877 uint8_t a_rate_index = 0;
1878 uint8_t b_rate_index = 0;
1879
1880 is_arate = 0;
1881
1882 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1883
1884 /* copy operational rate set from session_entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301885 qdf_mem_copy((temp_rate_set.rate), (session_entry->rateSet.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 session_entry->rateSet.numRates);
1887 temp_rate_set.numRates = (uint8_t) session_entry->rateSet.numRates;
1888
1889 if (phy_mode == WNI_CFG_PHY_MODE_11G) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301890 qdf_mem_copy((temp_rate_set2.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 (session_entry->extRateSet.rate),
1892 session_entry->extRateSet.numRates);
1893 temp_rate_set2.numRates =
1894 (uint8_t) session_entry->extRateSet.numRates;
1895 } else {
1896 temp_rate_set2.numRates = 0;
1897 }
1898
Naveen Rawat24c16912016-11-17 11:28:40 -08001899 /*
1900 * absolute sum of both num_rates should be less than 12. following
1901 * 16-bit sum avoids false codition where 8-bit arthematic overflow
1902 * might have caused total sum to be less than 12
1903 */
1904 if (((uint16_t)temp_rate_set.numRates +
1905 (uint16_t)temp_rate_set2.numRates) > 12) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001906 pe_err("more than 12 rates in CFG");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08001907 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 }
1909
1910 /*
1911 * Handling of the rate set IEs is the following:
1912 * - keep only rates that we support and that the station supports
1913 * - sort and the rates into the pSta->rate array
1914 */
1915
1916 /* Copy all rates in temp_rate_set, there are 12 rates max */
1917 for (i = 0; i < temp_rate_set2.numRates; i++)
1918 temp_rate_set.rate[i + temp_rate_set.numRates] =
1919 temp_rate_set2.rate[i];
1920
1921 temp_rate_set.numRates += temp_rate_set2.numRates;
1922
1923 /*
1924 * Sort rates in temp_rate_set (they are likely to be already sorted)
1925 * put the result in temp_rate_set2
1926 */
1927 temp_rate_set2.numRates = 0;
1928
1929 for (i = 0; i < temp_rate_set.numRates; i++) {
1930 min = 0;
1931 val = 0xff;
1932
1933 for (j = 0; j < temp_rate_set.numRates; j++)
1934 if ((uint32_t) (temp_rate_set.rate[j] & 0x7f) < val) {
1935 val = temp_rate_set.rate[j] & 0x7f;
1936 min = j;
1937 }
1938
1939 temp_rate_set2.rate[temp_rate_set2.numRates++] =
1940 temp_rate_set.rate[min];
1941 temp_rate_set.rate[min] = 0xff;
1942 }
1943
1944 /*
1945 * Copy received rates in temp_rate_set, the parser has ensured
1946 * unicity of the rates so there cannot be more than 12
1947 */
1948 for (i = 0; (i < oper_rate_set->numRates &&
1949 i < SIR_MAC_RATESET_EID_MAX); i++)
1950 temp_rate_set.rate[i] = oper_rate_set->rate[i];
1951
1952 temp_rate_set.numRates = oper_rate_set->numRates;
1953
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001954 pe_debug("Sum of SUPPORTED and EXTENDED Rate Set (%1d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 temp_rate_set.numRates + ext_rate_set->numRates);
1956
1957 if (ext_rate_set->numRates &&
1958 ((temp_rate_set.numRates + ext_rate_set->numRates) > 12) &&
1959 temp_rate_set.numRates < 12) {
1960 int found = 0;
1961 int tail = temp_rate_set.numRates;
1962
1963 for (i = 0; (i < ext_rate_set->numRates &&
1964 i < SIR_MAC_RATESET_EID_MAX); i++) {
1965 found = 0;
1966 for (j = 0; j < (uint32_t) tail; j++) {
1967 if ((temp_rate_set.rate[j] & 0x7F) ==
1968 (ext_rate_set->rate[i] & 0x7F)) {
1969 found = 1;
1970 break;
1971 }
1972 }
1973
1974 if (!found) {
1975 temp_rate_set.rate[temp_rate_set.numRates++] =
1976 ext_rate_set->rate[i];
1977 if (temp_rate_set.numRates >= 12)
1978 break;
1979 }
1980 }
1981 } else if (ext_rate_set->numRates &&
1982 ((temp_rate_set.numRates + ext_rate_set->numRates) <= 12)) {
1983 for (j = 0; ((j < ext_rate_set->numRates) &&
1984 (j < SIR_MAC_RATESET_EID_MAX) &&
1985 ((i + j) < SIR_MAC_RATESET_EID_MAX)); j++)
1986 temp_rate_set.rate[i + j] = ext_rate_set->rate[j];
1987
1988 temp_rate_set.numRates += ext_rate_set->numRates;
1989 } else if (ext_rate_set->numRates) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001990 pe_debug("Relying only on the SUPPORTED Rate Set IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 }
1992
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 rates = &sta_ds->supportedRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301994 qdf_mem_set((uint8_t *) rates, sizeof(tSirSupportedRates), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 for (i = 0; (i < temp_rate_set2.numRates &&
1996 i < SIR_MAC_RATESET_EID_MAX); i++) {
1997 for (j = 0; (j < temp_rate_set.numRates &&
1998 j < SIR_MAC_RATESET_EID_MAX); j++) {
1999 if ((temp_rate_set2.rate[i] & 0x7F) !=
2000 (temp_rate_set.rate[j] & 0x7F))
2001 continue;
2002
2003 if (sirIsArate(temp_rate_set2.rate[i] & 0x7f) &&
2004 a_rate_index < SIR_NUM_11A_RATES) {
2005 is_arate = 1;
2006 rates->llaRates[a_rate_index++] =
2007 temp_rate_set2.rate[i];
2008 } else if ((b_rate_index < SIR_NUM_11B_RATES) &&
2009 !(sirIsArate(temp_rate_set2.rate[i] & 0x7f))) {
2010 rates->llbRates[b_rate_index++] =
2011 temp_rate_set2.rate[i];
2012 }
2013 break;
2014 }
2015 }
2016
2017 /*
2018 * Now add the Polaris rates only when Proprietary rates are enabled.
2019 * compute the matching MCS rate set, if peer is 11n capable and self
2020 * mode is 11n
2021 */
2022#ifdef FEATURE_WLAN_TDLS
2023 if (sta_ds->mlmStaContext.htCapability)
2024#else
2025 if (IS_DOT11_MODE_HT(session_entry->dot11mode) &&
2026 (sta_ds->mlmStaContext.htCapability))
2027#endif
2028 {
2029 val = SIZE_OF_SUPPORTED_MCS_SET;
2030 if (wlan_cfg_get_str(mac_ctx, WNI_CFG_SUPPORTED_MCS_SET,
2031 mcs_set, &val) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002032 pe_err("could not retrieve supportedMCSet");
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -08002033 return eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 }
2035
Arif Hussain74fc5712016-07-20 11:10:01 -07002036 if (session_entry->nss == NSS_1x1_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07002037 mcs_set[1] = 0;
2038
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 for (i = 0; i < val; i++)
2040 sta_ds->supportedRates.supportedMCSSet[i] =
2041 mcs_set[i] & supported_mcs_set[i];
2042
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002043 pe_debug("lim_populate_matching_rate_set: MCS Rate Set Bitmap"
2044 " from CFG and DPH : ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002046 pe_debug("%x %x ", mcs_set[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 sta_ds->supportedRates.supportedMCSSet[i]);
2048 }
2049 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 lim_populate_vht_mcs_set(mac_ctx, &sta_ds->supportedRates, vht_caps,
Arif Hussain74fc5712016-07-20 11:10:01 -07002051 session_entry, session_entry->nss);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07002052 lim_populate_he_mcs_set(mac_ctx, &sta_ds->supportedRates, he_caps,
2053 session_entry, session_entry->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 /*
2055 * Set the erpEnabled bit if the phy is in G mode and at least
2056 * one A rate is supported
2057 */
2058 if ((phy_mode == WNI_CFG_PHY_MODE_11G) && is_arate)
2059 sta_ds->erpEnabled = eHAL_SET;
2060
2061 return eSIR_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062}
2063
2064/**
2065 * lim_populate_vht_caps() - populates vht capabilities based on input
2066 * capabilities
2067 * @input_caps: input capabilities based on which we format the vht
2068 * capabilities
2069 *
2070 * function to populate the supported vht capabilities.
2071 *
2072 * Return: vht capabilities derived based on input parameters.
2073 */
2074static uint32_t lim_populate_vht_caps(tDot11fIEVHTCaps input_caps)
2075{
2076 uint32_t vht_caps;
2077
2078 vht_caps = ((input_caps.maxMPDULen << SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
2079 (input_caps.supportedChannelWidthSet <<
2080 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
2081 (input_caps.ldpcCodingCap <<
2082 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
2083 (input_caps.shortGI80MHz <<
2084 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
2085 (input_caps.shortGI160and80plus80MHz <<
2086 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
2087 (input_caps.txSTBC << SIR_MAC_VHT_CAP_TXSTBC) |
2088 (input_caps.rxSTBC << SIR_MAC_VHT_CAP_RXSTBC) |
2089 (input_caps.suBeamFormerCap <<
2090 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
2091 (input_caps.suBeamformeeCap <<
2092 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
2093 (input_caps.csnofBeamformerAntSup <<
2094 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
2095 (input_caps.numSoundingDim <<
2096 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
2097 (input_caps.muBeamformerCap <<
2098 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
2099 (input_caps.muBeamformeeCap <<
2100 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
2101 (input_caps.vhtTXOPPS <<
2102 SIR_MAC_VHT_CAP_TXOPPS) |
2103 (input_caps.htcVHTCap <<
2104 SIR_MAC_VHT_CAP_HTC_CAP) |
2105 (input_caps.maxAMPDULenExp <<
2106 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
2107 (input_caps.vhtLinkAdaptCap <<
2108 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
2109 (input_caps.rxAntPattern <<
2110 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
2111 (input_caps.txAntPattern <<
2112 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
2113 (input_caps.reserved1 <<
2114 SIR_MAC_VHT_CAP_RESERVED2));
2115
2116 return vht_caps;
2117}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119/**
Arif Hussain53cf5692018-04-05 16:35:54 -07002120 * lim_update_he_stbc_capable() - Update stbc capable flag based on
2121 * HE capability
2122 * @add_sta_params: add sta related parameters
2123 *
2124 * Update stbc cpable flag based on HE capability
2125 *
2126 * Return: None
2127 */
2128#ifdef WLAN_FEATURE_11AX
2129static void lim_update_he_stbc_capable(tpAddStaParams add_sta_params)
2130{
2131 if (add_sta_params &&
2132 add_sta_params->he_capable &&
2133 add_sta_params->stbc_capable)
2134 add_sta_params->stbc_capable =
2135 add_sta_params->he_config.rx_stbc_lt_80mhz;
2136}
2137#else
2138static void lim_update_he_stbc_capable(tpAddStaParams add_sta_params)
2139{}
2140#endif
2141
2142/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 * lim_add_sta()- called to add an STA context at hardware
2144 * @mac_ctx: pointer to global mac structure
2145 * @sta_ds: station node
2146 * @update_entry: set to true for updating the entry
2147 * @session_entry: pe session entry
2148 *
2149 * This function is called to add an STA context at hardware
2150 * whenever a STA is (Re) Associated.
2151 *
2152 * Return: eSIR_SUCCESS on success else eSirRetStatus failure codes
2153 */
2154
2155tSirRetStatus
2156lim_add_sta(tpAniSirGlobal mac_ctx,
2157 tpDphHashNode sta_ds, uint8_t update_entry, tpPESession session_entry)
2158{
2159 tpAddStaParams add_sta_params = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002160 struct scheduler_msg msg_q = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 tSirRetStatus ret_code = eSIR_SUCCESS;
2162 tSirMacAddr sta_mac, *sta_Addr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 tpSirAssocReq assoc_req;
Kiran Kumar Lokere80d3e1a2017-05-26 15:15:13 -07002164 uint8_t i, nw_type_11b = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 tLimIbssPeerNode *peer_node; /* for IBSS mode */
Naveen Rawat08db88f2017-09-08 15:07:48 -07002166 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167
2168 sir_copy_mac_addr(sta_mac, session_entry->selfMacAddr);
2169
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002170 pe_debug("sessionid: %d update_entry = %d limsystemrole = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 session_entry->smeSessionId, update_entry,
2172 GET_LIM_SYSTEM_ROLE(session_entry));
2173
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302174 add_sta_params = qdf_mem_malloc(sizeof(tAddStaParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 if (NULL == add_sta_params) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002176 pe_err("Unable to allocate memory during ADD_STA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 return eSIR_MEM_ALLOC_FAILED;
2178 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179
Naveen Rawatcb186cf2016-07-11 13:47:19 -07002180 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry) ||
2181 LIM_IS_NDI_ROLE(session_entry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002182 sta_Addr = &sta_ds->staAddr;
2183#ifdef FEATURE_WLAN_TDLS
2184 /* SystemRole shouldn't be matter if staType is TDLS peer */
2185 else if (STA_ENTRY_TDLS_PEER == sta_ds->staType)
2186 sta_Addr = &sta_ds->staAddr;
2187#endif
2188 else
2189 sta_Addr = &sta_mac;
2190
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002191 pe_debug(MAC_ADDRESS_STR ": Subtype(Assoc/Reassoc): %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 MAC_ADDR_ARRAY(*sta_Addr), sta_ds->mlmStaContext.subType);
2193
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302194 qdf_mem_copy((uint8_t *) add_sta_params->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195 (uint8_t *) *sta_Addr, sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302196 qdf_mem_copy((uint8_t *) add_sta_params->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 session_entry->bssId, sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302198 qdf_mem_copy(&add_sta_params->capab_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 &sta_ds->mlmStaContext.capabilityInfo,
2200 sizeof(add_sta_params->capab_info));
2201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 /* Copy legacy rates */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302203 qdf_mem_copy((uint8_t *) &add_sta_params->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 (uint8_t *) &sta_ds->supportedRates,
2205 sizeof(tSirSupportedRates));
2206
2207 add_sta_params->assocId = sta_ds->assocId;
2208
2209 add_sta_params->wmmEnabled = sta_ds->qosMode;
2210 add_sta_params->listenInterval = sta_ds->mlmStaContext.listenInterval;
2211 add_sta_params->shortPreambleSupported = sta_ds->shortPreambleEnabled;
2212 if (LIM_IS_AP_ROLE(session_entry) &&
2213 (sta_ds->mlmStaContext.subType == LIM_REASSOC)) {
2214 /*
2215 * TBD - need to remove this REASSOC check
2216 * after fixinf rmmod issue
2217 */
2218 add_sta_params->updateSta = sta_ds->mlmStaContext.updateContext;
2219 }
2220 sta_ds->valid = 0;
2221 sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2222
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002223 pe_debug("Assoc ID: %d wmmEnabled: %d listenInterval: %d"
2224 " shortPreambleSupported: %d", add_sta_params->assocId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 add_sta_params->wmmEnabled, add_sta_params->listenInterval,
2226 add_sta_params->shortPreambleSupported);
2227 /* This will indicate HAL to "allocate" a new STA index */
2228#ifdef FEATURE_WLAN_TDLS
2229 /*
2230 * As there is corner case in-between add_sta and change_sta,if del_sta
2231 * for other staIdx happened, firmware return wrong staIdx
2232 * (recently removed staIdx). Until we get a confirmation from the
2233 * firmware team it is now return correct staIdx for same sta_mac_addr
2234 * for update case, we want to get around it by passing valid staIdx
2235 * given by add_sta time.
2236 */
2237 if ((STA_ENTRY_TDLS_PEER == sta_ds->staType) && (true == update_entry))
2238 add_sta_params->staIdx = sta_ds->staIndex;
2239 else
2240#endif
2241 add_sta_params->staIdx = STA_INVALID_IDX;
2242 add_sta_params->staType = sta_ds->staType;
2243
2244 add_sta_params->updateSta = update_entry;
2245
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302246 add_sta_params->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 add_sta_params->respReqd = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248
Abhishek Singha91d6192017-08-16 17:24:17 +05302249 /* Update VHT/HT Capability */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 if (LIM_IS_AP_ROLE(session_entry) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 LIM_IS_IBSS_ROLE(session_entry)) {
2252 add_sta_params->htCapable = sta_ds->mlmStaContext.htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 add_sta_params->vhtCapable =
2254 sta_ds->mlmStaContext.vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 }
Abhishek Singha91d6192017-08-16 17:24:17 +05302256#ifdef FEATURE_WLAN_TDLS
2257 /* SystemRole shouldn't be matter if staType is TDLS peer */
2258 else if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
2259 add_sta_params->htCapable = sta_ds->mlmStaContext.htCapability;
2260 add_sta_params->vhtCapable =
2261 sta_ds->mlmStaContext.vhtCapability;
2262 }
2263#endif
2264 else {
2265 add_sta_params->htCapable = session_entry->htCapability;
2266 add_sta_params->vhtCapable = session_entry->vhtCapability;
2267 }
2268
2269 pe_debug("StaIdx: %d updateSta: %d htcapable: %d vhtCapable: %d",
2270 add_sta_params->staIdx, add_sta_params->updateSta,
2271 add_sta_params->htCapable, add_sta_params->vhtCapable);
2272
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002273 /*
Naveen Rawat903acca2017-09-15 17:32:13 -07002274 * If HT client is connected to SAP DUT and self cap is NSS = 2 then
2275 * disable ASYNC DBS scan by sending WMI_VDEV_PARAM_SMPS_INTOLERANT
2276 * to FW, because HT client's can't drop down chain using SMPS frames.
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002277 */
2278 if (!policy_mgr_is_hw_dbs_2x2_capable(mac_ctx->psoc) &&
2279 LIM_IS_AP_ROLE(session_entry) &&
2280 (STA_ENTRY_PEER == sta_ds->staType) &&
2281 !add_sta_params->vhtCapable &&
2282 (session_entry->nss == 2)) {
2283 session_entry->ht_client_cnt++;
Naveen Rawat903acca2017-09-15 17:32:13 -07002284 if (session_entry->ht_client_cnt == 1) {
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002285 pe_debug("setting SMPS intolrent vdev_param");
2286 wma_cli_set_command(session_entry->smeSessionId,
2287 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
2288 1, VDEV_CMD);
2289 }
2290 }
2291
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002292 lim_update_sta_he_capable(mac_ctx, add_sta_params, sta_ds,
2293 session_entry);
2294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 add_sta_params->greenFieldCapable = sta_ds->htGreenfield;
2296 add_sta_params->maxAmpduDensity = sta_ds->htAMpduDensity;
2297 add_sta_params->maxAmpduSize = sta_ds->htMaxRxAMpduFactor;
2298 add_sta_params->fDsssCckMode40Mhz = sta_ds->htDsssCckRate40MHzSupport;
2299 add_sta_params->fShortGI20Mhz = sta_ds->htShortGI20Mhz;
2300 add_sta_params->fShortGI40Mhz = sta_ds->htShortGI40Mhz;
2301 add_sta_params->lsigTxopProtection = sta_ds->htLsigTXOPProtection;
2302 add_sta_params->maxAmsduSize = sta_ds->htMaxAmsduLength;
2303 add_sta_params->ch_width = sta_ds->htSupportedChannelWidthSet;
2304 add_sta_params->mimoPS = sta_ds->htMIMOPSState;
2305
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002306 pe_debug("greenFieldCapable: %d maxAmpduDensity: %d maxAmpduDensity: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 add_sta_params->greenFieldCapable,
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002308 add_sta_params->maxAmpduDensity, add_sta_params->maxAmpduSize);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002310 pe_debug("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d fShortGI40Mhz: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 add_sta_params->fDsssCckMode40Mhz,
2312 add_sta_params->fShortGI20Mhz, add_sta_params->fShortGI40Mhz);
2313
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002314 pe_debug("lsigTxopProtection: %d maxAmsduSize: %d txChannelWidth: %d mimoPS: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 add_sta_params->lsigTxopProtection,
2316 add_sta_params->maxAmsduSize, add_sta_params->ch_width,
2317 add_sta_params->mimoPS);
2318
2319 if (add_sta_params->vhtCapable) {
2320 if (sta_ds->vhtSupportedChannelWidthSet)
2321 add_sta_params->ch_width =
2322 sta_ds->vhtSupportedChannelWidthSet + 1;
2323
2324 add_sta_params->vhtSupportedRxNss = sta_ds->vhtSupportedRxNss;
Kiran Kumar Lokeref1f5e992016-06-20 16:48:50 -07002325 if (LIM_IS_AP_ROLE(session_entry) ||
2326 LIM_IS_P2P_DEVICE_GO(session_entry))
2327 add_sta_params->vhtSupportedRxNss = QDF_MIN(
2328 add_sta_params->vhtSupportedRxNss,
2329 session_entry->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 add_sta_params->vhtTxBFCapable =
2331#ifdef FEATURE_WLAN_TDLS
2332 ((STA_ENTRY_PEER == sta_ds->staType)
2333 || (STA_ENTRY_TDLS_PEER == sta_ds->staType)) ?
Krunal Soni53993f72016-07-08 18:20:03 -07002334 sta_ds->vhtBeamFormerCapable :
2335 session_entry->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336#else
2337 (STA_ENTRY_PEER == sta_ds->staType) ?
Krunal Soni53993f72016-07-08 18:20:03 -07002338 sta_ds->vhtBeamFormerCapable :
2339 session_entry->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340#endif
2341 add_sta_params->enable_su_tx_bformer =
2342 sta_ds->vht_su_bfee_capable;
2343 }
2344
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002345 pe_debug("TxChWidth %d vhtTxBFCap %d, su_bfer %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346 add_sta_params->ch_width, add_sta_params->vhtTxBFCapable,
2347 add_sta_params->enable_su_tx_bformer);
2348#ifdef FEATURE_WLAN_TDLS
2349 if ((STA_ENTRY_PEER == sta_ds->staType) ||
2350 (STA_ENTRY_TDLS_PEER == sta_ds->staType))
2351#else
2352 if (STA_ENTRY_PEER == sta_ds->staType)
2353#endif
2354 {
2355 /*
2356 * peer STA get the LDPC capability from sta_ds,
2357 * which populated from
2358 * HT/VHT capability
2359 */
2360 if (add_sta_params->vhtTxBFCapable
2361 && mac_ctx->lim.disableLDPCWithTxbfAP) {
2362 add_sta_params->htLdpcCapable = 0;
2363 add_sta_params->vhtLdpcCapable = 0;
2364 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08002365 if (session_entry->txLdpcIniFeatureEnabled & 0x1)
2366 add_sta_params->htLdpcCapable =
2367 sta_ds->htLdpcCapable;
2368 else
2369 add_sta_params->htLdpcCapable = 0;
2370
2371 if (session_entry->txLdpcIniFeatureEnabled & 0x2)
2372 add_sta_params->vhtLdpcCapable =
2373 sta_ds->vhtLdpcCapable;
2374 else
2375 add_sta_params->vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 }
2377 } else if (STA_ENTRY_SELF == sta_ds->staType) {
2378 /* For Self STA get the LDPC capability from config.ini */
2379 add_sta_params->htLdpcCapable =
2380 (session_entry->txLdpcIniFeatureEnabled & 0x01);
2381 add_sta_params->vhtLdpcCapable =
2382 ((session_entry->txLdpcIniFeatureEnabled >> 1) & 0x01);
2383 }
2384
2385 /* Update PE session ID */
2386 add_sta_params->sessionId = session_entry->peSessionId;
2387
2388 /* Update SME session ID */
2389 add_sta_params->smesessionId = session_entry->smeSessionId;
2390
2391 add_sta_params->maxTxPower = session_entry->maxTxPower;
2392
2393 if (session_entry->parsedAssocReq != NULL) {
2394 uint16_t aid = sta_ds->assocId;
2395 /* Get a copy of the already parsed Assoc Request */
2396 assoc_req =
2397 (tpSirAssocReq) session_entry->parsedAssocReq[aid];
2398 if (assoc_req && assoc_req->addIEPresent
2399 && assoc_req->addIE.length) {
2400 p2p_ie = limGetP2pIEPtr(mac_ctx,
2401 assoc_req->addIE.addIEdata,
2402 assoc_req->addIE.length);
2403 }
2404
2405 add_sta_params->p2pCapableSta = (p2p_ie != NULL);
2406 if (assoc_req && add_sta_params->htCapable) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302407 qdf_mem_copy(&add_sta_params->ht_caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 ((uint8_t *) &assoc_req->HTCaps) + 1,
2409 sizeof(add_sta_params->ht_caps));
2410 }
2411
2412 if (assoc_req && add_sta_params->vhtCapable)
2413 add_sta_params->vht_caps =
2414 lim_populate_vht_caps(assoc_req->VHTCaps);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002415
2416 lim_add_he_cap(add_sta_params, assoc_req);
2417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 } else if (LIM_IS_IBSS_ROLE(session_entry)) {
2419
2420 /*
2421 * in IBSS mode, use peer node as the source of ht_caps
2422 * and vht_caps
2423 */
2424 peer_node = lim_ibss_peer_find(mac_ctx, *sta_Addr);
2425 if (!peer_node) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002426 pe_err("Can't find IBSS peer node for ADD_STA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 return eSIR_HAL_STA_DOES_NOT_EXIST;
2428 }
2429
2430 if (peer_node->atimIePresent) {
2431 add_sta_params->atimIePresent =
2432 peer_node->atimIePresent;
2433 add_sta_params->peerAtimWindowLength =
2434 peer_node->peerAtimWindowLength;
2435 }
2436
2437 add_sta_params->ht_caps =
2438 (peer_node->htSupportedChannelWidthSet <<
2439 SIR_MAC_HT_CAP_CHWIDTH40_S) |
2440 (peer_node->htGreenfield <<
2441 SIR_MAC_HT_CAP_GREENFIELD_S) |
2442 (peer_node->htShortGI20Mhz <<
2443 SIR_MAC_HT_CAP_SHORTGI20MHZ_S) |
2444 (peer_node->htShortGI40Mhz <<
2445 SIR_MAC_HT_CAP_SHORTGI40MHZ_S) |
2446 (SIR_MAC_TXSTBC <<
2447 SIR_MAC_HT_CAP_TXSTBC_S) |
2448 (SIR_MAC_RXSTBC <<
2449 SIR_MAC_HT_CAP_RXSTBC_S) |
2450 (peer_node->htMaxAmsduLength <<
2451 SIR_MAC_HT_CAP_MAXAMSDUSIZE_S) |
2452 (peer_node->htDsssCckRate40MHzSupport <<
2453 SIR_MAC_HT_CAP_DSSSCCK40_S);
2454
2455 add_sta_params->vht_caps =
2456 lim_populate_vht_caps(peer_node->VHTCaps);
2457 }
2458#ifdef FEATURE_WLAN_TDLS
2459 if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
2460 add_sta_params->ht_caps = sta_ds->ht_caps;
2461 add_sta_params->vht_caps = sta_ds->vht_caps;
2462
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002463 pe_debug("Sta type is TDLS_PEER, ht_caps: 0x%x, vht_caps: 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 add_sta_params->ht_caps,
2465 add_sta_params->vht_caps);
2466 }
2467#endif
2468
2469#ifdef FEATURE_WLAN_TDLS
2470 if (sta_ds->wmeEnabled &&
2471 (LIM_IS_AP_ROLE(session_entry) ||
2472 (STA_ENTRY_TDLS_PEER == sta_ds->staType)))
2473#else
2474 if (sta_ds->wmeEnabled && LIM_IS_AP_ROLE(session_entry))
2475#endif
2476 {
2477 add_sta_params->uAPSD = 0;
2478 /*
2479 * update UAPSD and send it to LIM to add STA
2480 * bitmap MSB <- LSB MSB 4 bits are for
2481 * trigger enabled AC setting and LSB 4 bits
2482 * are for delivery enabled AC setting
2483 * 7 6 5 4 3 2 1 0
2484 * BE BK VI VO BE BK VI VO
2485 */
2486 add_sta_params->uAPSD |=
2487 sta_ds->qos.capability.qosInfo.acvo_uapsd;
2488 add_sta_params->uAPSD |=
2489 (sta_ds->qos.capability.qosInfo.acvi_uapsd << 1);
2490 add_sta_params->uAPSD |=
2491 (sta_ds->qos.capability.qosInfo.acbk_uapsd << 2);
2492 add_sta_params->uAPSD |=
2493 (sta_ds->qos.capability.qosInfo.acbe_uapsd << 3);
2494 /*
2495 * making delivery enabled and
2496 * trigger enabled setting the same.
2497 */
2498 add_sta_params->uAPSD |= add_sta_params->uAPSD << 4;
2499
2500 add_sta_params->maxSPLen =
2501 sta_ds->qos.capability.qosInfo.maxSpLen;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002502 pe_debug("uAPSD = 0x%x, maxSpLen = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 add_sta_params->uAPSD, add_sta_params->maxSPLen);
2504 }
2505#ifdef WLAN_FEATURE_11W
2506 add_sta_params->rmfEnabled = sta_ds->rmfEnabled;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002507 pe_debug("PMF enabled %d", add_sta_params->rmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508#endif
2509
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002510 pe_debug("htLdpcCapable: %d vhtLdpcCapable: %d "
2511 "p2pCapableSta: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 add_sta_params->htLdpcCapable, add_sta_params->vhtLdpcCapable,
2513 add_sta_params->p2pCapableSta);
2514
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08002515 if (!add_sta_params->htLdpcCapable)
2516 add_sta_params->ht_caps &= ~(1 << SIR_MAC_HT_CAP_ADVCODING_S);
2517 if (!add_sta_params->vhtLdpcCapable)
2518 add_sta_params->vht_caps &=
2519 ~(1 << SIR_MAC_VHT_CAP_LDPC_CODING_CAP);
2520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 /*
2522 * we need to defer the message until we get the
2523 * response back from HAL.
2524 */
2525 if (add_sta_params->respReqd)
2526 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, false);
2527
yeshwanth sriram guntuka47f26e62017-03-07 12:43:02 +05302528 add_sta_params->nwType = session_entry->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529
Kiran Kumar Lokere80d3e1a2017-05-26 15:15:13 -07002530 if (!(add_sta_params->htCapable || add_sta_params->vhtCapable)) {
2531 nw_type_11b = 1;
2532 for (i = 0; i < SIR_NUM_11A_RATES; i++) {
2533 if (sirIsArate(sta_ds->supportedRates.llaRates[i] &
2534 0x7F)) {
2535 nw_type_11b = 0;
2536 break;
2537 }
2538 }
2539 if (nw_type_11b)
2540 add_sta_params->nwType = eSIR_11B_NW_TYPE;
2541 }
2542
Arif Hussain53cf5692018-04-05 16:35:54 -07002543 if (add_sta_params->htCapable && session_entry->htConfig.ht_tx_stbc) {
2544 struct sDot11fIEHTCaps *ht_caps = (struct sDot11fIEHTCaps *)
2545 &add_sta_params->ht_caps;
2546 if (ht_caps->rxSTBC)
2547 add_sta_params->stbc_capable = 1;
2548 else
2549 add_sta_params->stbc_capable = 0;
2550 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551
Arif Hussain53cf5692018-04-05 16:35:54 -07002552 if (add_sta_params->vhtCapable && add_sta_params->stbc_capable) {
2553 struct sDot11fIEVHTCaps *vht_caps = (struct sDot11fIEVHTCaps *)
2554 &add_sta_params->vht_caps;
2555 if (vht_caps->rxSTBC)
2556 add_sta_params->stbc_capable = 1;
2557 else
2558 add_sta_params->stbc_capable = 0;
2559 }
2560
2561 lim_update_he_stbc_capable(add_sta_params);
2562
2563 msg_q.type = WMA_ADD_STA_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 msg_q.reserved = 0;
2565 msg_q.bodyptr = add_sta_params;
2566 msg_q.bodyval = 0;
2567
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002568 pe_debug("Sending WMA_ADD_STA_REQ for assocId %d", sta_ds->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId,
2570 msg_q.type));
2571
2572 ret_code = wma_post_ctrl_msg(mac_ctx, &msg_q);
2573 if (eSIR_SUCCESS != ret_code) {
2574 if (add_sta_params->respReqd)
2575 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002576 pe_err("ADD_STA_REQ for aId %d failed (reason %X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 sta_ds->assocId, ret_code);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302578 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 }
2580
2581 return ret_code;
2582}
2583
2584/**
2585 * lim_del_sta()
2586 *
2587 ***FUNCTION:
2588 * This function is called to delete an STA context at hardware
2589 * whenever a STA is disassociated
2590 *
2591 ***LOGIC:
2592 *
2593 ***ASSUMPTIONS:
2594 * NA
2595 *
2596 ***NOTE:
2597 * NA
2598 *
2599 * @param pMac - Pointer to Global MAC structure
2600 * @param pStaDs - Pointer to the STA datastructure created by
2601 * LIM and maintained by DPH
2602 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2603 * or not (false)
2604 * @return retCode - Indicates success or failure return code
2605 */
2606
2607tSirRetStatus
2608lim_del_sta(tpAniSirGlobal pMac,
2609 tpDphHashNode pStaDs, bool fRespReqd, tpPESession psessionEntry)
2610{
2611 tpDeleteStaParams pDelStaParams = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002612 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 tSirRetStatus retCode = eSIR_SUCCESS;
2614
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302615 pDelStaParams = qdf_mem_malloc(sizeof(tDeleteStaParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 if (NULL == pDelStaParams) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002617 pe_err("Unable to allocate memory during ADD_STA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 return eSIR_MEM_ALLOC_FAILED;
2619 }
2620
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002621 /*
2622 * 2G-AS platform: SAP associates with HT (11n)clients as 2x1 in 2G and
2623 * 2X2 in 5G
2624 * Non-2G-AS platform: SAP associates with HT (11n) clients as 2X2 in 2G
2625 * and 5G; and enable async dbs scan when all HT clients are gone
2626 * 5G-AS: Don't care
2627 */
2628 if (!policy_mgr_is_hw_dbs_2x2_capable(pMac->psoc) &&
2629 LIM_IS_AP_ROLE(psessionEntry) &&
2630 (pStaDs->staType == STA_ENTRY_PEER) &&
2631 !pStaDs->mlmStaContext.vhtCapability &&
2632 (psessionEntry->nss == 2)) {
2633 psessionEntry->ht_client_cnt--;
2634 if (psessionEntry->ht_client_cnt == 0) {
2635 pe_debug("clearing SMPS intolrent vdev_param");
2636 wma_cli_set_command(psessionEntry->smeSessionId,
2637 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
2638 0, VDEV_CMD);
2639 }
2640 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 /* */
2642 /* DPH contains the STA index only for "peer" STA entries. */
2643 /* LIM global contains "self" STA index */
2644 /* Thus, */
2645 /* if( STA role ) */
2646 /* get STA index from LIM global */
2647 /* else */
2648 /* get STA index from DPH */
2649 /* */
2650
2651#ifdef FEATURE_WLAN_TDLS
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07002652 if (LIM_IS_STA_ROLE(psessionEntry) &&
2653 (pStaDs->staType != STA_ENTRY_TDLS_PEER))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654#else
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07002655 if (LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656#endif
2657 pDelStaParams->staIdx = psessionEntry->staId;
2658
2659 else
2660 pDelStaParams->staIdx = pStaDs->staIndex;
2661
2662 pDelStaParams->assocId = pStaDs->assocId;
2663 pStaDs->valid = 0;
2664
2665 if (!fRespReqd)
2666 pDelStaParams->respReqd = 0;
2667 else {
Yingying Tanga1863be2017-03-22 18:10:43 +08002668 if (!(IS_TDLS_PEER(pStaDs->staType))) {
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302669 /* when lim_del_sta is called from processSmeAssocCnf
2670 * then mlmState is already set properly. */
2671 if (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
2672 GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs)) {
2673 MTRACE(mac_trace
2674 (pMac, TRACE_CODE_MLM_STATE,
2675 psessionEntry->peSessionId,
2676 eLIM_MLM_WT_DEL_STA_RSP_STATE));
2677 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs,
2678 eLIM_MLM_WT_DEL_STA_RSP_STATE);
2679 }
2680 if (LIM_IS_STA_ROLE(psessionEntry)) {
2681 MTRACE(mac_trace
2682 (pMac, TRACE_CODE_MLM_STATE,
2683 psessionEntry->peSessionId,
2684 eLIM_MLM_WT_DEL_STA_RSP_STATE));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302686 psessionEntry->limMlmState =
2687 eLIM_MLM_WT_DEL_STA_RSP_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302689 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 }
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302691
2692 /* we need to defer the message until we get the
2693 * response back from HAL. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302695
2696 pDelStaParams->respReqd = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 }
2698
2699 /* Update PE session ID */
2700 pDelStaParams->sessionId = psessionEntry->peSessionId;
2701 pDelStaParams->smesessionId = psessionEntry->smeSessionId;
2702
2703 pDelStaParams->staType = pStaDs->staType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302704 qdf_mem_copy((uint8_t *) pDelStaParams->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 (uint8_t *) pStaDs->staAddr, sizeof(tSirMacAddr));
2706
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302707 pDelStaParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 msgQ.type = WMA_DELETE_STA_REQ;
2709 msgQ.reserved = 0;
2710 msgQ.bodyptr = pDelStaParams;
2711 msgQ.bodyval = 0;
2712
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002713 pe_debug("Sessionid %d :Sending SIR_HAL_DELETE_STA_REQ "
2714 "for STAID: %X and AssocID: %d MAC : "
2715 MAC_ADDRESS_STR, pDelStaParams->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 pDelStaParams->staIdx, pDelStaParams->assocId,
2717 MAC_ADDR_ARRAY(pStaDs->staAddr));
2718
2719 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
2720 retCode = wma_post_ctrl_msg(pMac, &msgQ);
2721 if (eSIR_SUCCESS != retCode) {
2722 if (fRespReqd)
2723 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002724 pe_err("Posting DELETE_STA_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302726 qdf_mem_free(pDelStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727 }
2728
2729 return retCode;
2730}
2731
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732
2733/**
2734 * lim_add_sta_self()
2735 *
2736 ***FUNCTION:
2737 * This function is called to add an STA context at hardware
2738 * whenever a STA is (Re) Associated.
2739 *
2740 ***LOGIC:
2741 *
2742 ***ASSUMPTIONS:
2743 * NA
2744 *
2745 ***NOTE:
2746 * NA
2747 *
2748 * @param pMac - Pointer to Global MAC structure
2749 * @param pStaDs - Pointer to the STA datastructure created by
2750 * LIM and maintained by DPH
2751 * @return retCode - Indicates success or failure return code
2752 */
2753
2754tSirRetStatus
2755lim_add_sta_self(tpAniSirGlobal pMac, uint16_t staIdx, uint8_t updateSta,
2756 tpPESession psessionEntry)
2757{
2758 tpAddStaParams pAddStaParams = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002759 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 tSirRetStatus retCode = eSIR_SUCCESS;
2761 tSirMacAddr staMac;
2762 uint32_t listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 uint32_t ampduLenExponent = 0;
2764 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2765 * that cfg carries the systemwide capability that device under
2766 * consideration can support. This capability gets plumbed into the cfg
2767 * cache at system initialization time via the .dat and .ini file override
2768 * mechanisms and will not change. If it does change, it is the
2769 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2770 * command.*/
2771 uint32_t selfStaDot11Mode = 0, selfTxWidth = 0;
2772 uint32_t val;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 wlan_cfg_get_int(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 wlan_cfg_get_int(pMac, WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,
2776 &selfTxWidth);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002777 pe_debug("cfgDot11Mode: %d selfTxWidth: %d",
2778 (int)selfStaDot11Mode, (int)selfTxWidth);
2779 pe_debug("Roam Channel Bonding Mode %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 (int)pMac->roam.configParam.uCfgDot11Mode);
2781
2782 sir_copy_mac_addr(staMac, psessionEntry->selfMacAddr);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002783 pe_debug(MAC_ADDRESS_STR ": ", MAC_ADDR_ARRAY(staMac));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302784 pAddStaParams = qdf_mem_malloc(sizeof(tAddStaParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 if (NULL == pAddStaParams) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002786 pe_err("Unable to allocate memory during ADD_STA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 return eSIR_MEM_ALLOC_FAILED;
2788 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789
2790 /* / Add STA context at MAC HW (BMU, RHP & TFP) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302791 qdf_mem_copy((uint8_t *) pAddStaParams->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 (uint8_t *) staMac, sizeof(tSirMacAddr));
2793
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302794 qdf_mem_copy((uint8_t *) pAddStaParams->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 psessionEntry->bssId, sizeof(tSirMacAddr));
2796
2797 pAddStaParams->assocId = psessionEntry->limAID;
2798 pAddStaParams->staType = STA_ENTRY_SELF;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302799 pAddStaParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 pAddStaParams->respReqd = 1;
2801
2802 /* Update PE session ID */
2803 pAddStaParams->sessionId = psessionEntry->peSessionId;
2804
2805 /* Update SME session ID */
2806 pAddStaParams->smesessionId = psessionEntry->smeSessionId;
2807
2808 pAddStaParams->maxTxPower = psessionEntry->maxTxPower;
2809
2810 /* This will indicate HAL to "allocate" a new STA index */
2811 pAddStaParams->staIdx = staIdx;
2812 pAddStaParams->updateSta = updateSta;
2813
2814 if (wlan_cfg_get_int(pMac, WNI_CFG_SHORT_PREAMBLE, &val) !=
2815 eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002816 pe_err("Couldn't get SHORT_PREAMBLE, set default");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 pAddStaParams->shortPreambleSupported = 1;
2818 } else {
2819 pAddStaParams->shortPreambleSupported = val;
2820 }
2821
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 lim_populate_own_rate_set(pMac, &pAddStaParams->supportedRates, NULL, false,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07002823 psessionEntry, NULL, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 if (IS_DOT11_MODE_HT(selfStaDot11Mode)) {
2825 pAddStaParams->htCapable = true;
2826#ifdef DISABLE_GF_FOR_INTEROP
2827 if ((psessionEntry->pLimJoinReq != NULL)
2828 && (!psessionEntry->pLimJoinReq->bssDescription.
2829 aniIndicator)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002830 pe_err("Turning off Greenfield, when adding self entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 pAddStaParams->greenFieldCapable =
2832 WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2833 } else
2834#endif
2835 {
2836 pAddStaParams->greenFieldCapable =
2837 lim_get_ht_capability(pMac, eHT_GREENFIELD,
2838 psessionEntry);
2839 pAddStaParams->ch_width =
2840 pMac->roam.configParam.channelBondingMode5GHz;
2841 pAddStaParams->mimoPS =
2842 lim_get_ht_capability(pMac, eHT_MIMO_POWER_SAVE,
2843 psessionEntry);
2844 pAddStaParams->rifsMode =
2845 lim_get_ht_capability(pMac, eHT_RIFS_MODE,
2846 psessionEntry);
2847 pAddStaParams->lsigTxopProtection =
2848 lim_get_ht_capability(pMac, eHT_LSIG_TXOP_PROTECTION,
2849 psessionEntry);
2850 pAddStaParams->maxAmpduDensity =
2851 lim_get_ht_capability(pMac, eHT_MPDU_DENSITY,
2852 psessionEntry);
2853 pAddStaParams->maxAmpduSize =
2854 lim_get_ht_capability(pMac, eHT_MAX_RX_AMPDU_FACTOR,
2855 psessionEntry);
2856 pAddStaParams->maxAmsduSize =
2857 lim_get_ht_capability(pMac, eHT_MAX_AMSDU_LENGTH,
2858 psessionEntry);
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002859 pAddStaParams->max_amsdu_num =
2860 lim_get_ht_capability(pMac, eHT_MAX_AMSDU_NUM,
2861 psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 pAddStaParams->fDsssCckMode40Mhz =
2863 lim_get_ht_capability(pMac, eHT_DSSS_CCK_MODE_40MHZ,
2864 psessionEntry);
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07002865 pAddStaParams->fShortGI20Mhz =
2866 psessionEntry->htConfig.ht_sgi20;
2867 pAddStaParams->fShortGI40Mhz =
2868 psessionEntry->htConfig.ht_sgi40;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002869 pe_debug("greenFieldCapable: %d maxAmpduDensity: %d "
2870 "maxAmpduSize: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 pAddStaParams->greenFieldCapable,
2872 pAddStaParams->maxAmpduDensity,
2873 pAddStaParams->maxAmpduSize);
2874
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002875 pe_debug("fDsssCckMode40Mhz: %d fShortGI20Mhz: %d "
2876 "fShortGI40Mhz: %d lsigTxopProtection: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 pAddStaParams->fDsssCckMode40Mhz,
2878 pAddStaParams->fShortGI20Mhz,
2879 pAddStaParams->fShortGI40Mhz,
2880 pAddStaParams->lsigTxopProtection);
2881
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002882 pe_debug("maxAmsduSize: %d txChannelWidth: %d mimoPS: %d rifsMode %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 pAddStaParams->maxAmsduSize,
2884 pAddStaParams->ch_width,
2885 pAddStaParams->mimoPS, pAddStaParams->rifsMode);
2886 }
2887 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
2889 if (pAddStaParams->vhtCapable) {
2890 pAddStaParams->ch_width =
2891 psessionEntry->ch_width;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002892 pe_debug("VHT WIDTH SET %d", pAddStaParams->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 }
Krunal Soni53993f72016-07-08 18:20:03 -07002894 pAddStaParams->vhtTxBFCapable =
2895 psessionEntry->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 pAddStaParams->enable_su_tx_bformer =
Krunal Soni53993f72016-07-08 18:20:03 -07002897 psessionEntry->vht_config.su_beam_former;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002898 pe_debug("vhtCapable: %d vhtTxBFCapable %d, su_bfer %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 pAddStaParams->vhtCapable, pAddStaParams->vhtTxBFCapable,
2900 pAddStaParams->enable_su_tx_bformer);
2901
2902 /* In 11ac mode, the hardware is capable of supporting 128K AMPDU size */
2903 if (IS_DOT11_MODE_VHT(selfStaDot11Mode)) {
2904 if (wlan_cfg_get_int
2905 (pMac, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &ampduLenExponent)
2906 != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002907 pe_err("Couldn't get WNI_CFG_VHT_AMPDU_LEN_EXPONENT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 }
2909 pAddStaParams->maxAmpduSize = (uint8_t) ampduLenExponent;
2910 }
Krunal Soni53993f72016-07-08 18:20:03 -07002911 pAddStaParams->vhtTxMUBformeeCapable =
2912 psessionEntry->vht_config.mu_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 pAddStaParams->enableVhtpAid = psessionEntry->enableVhtpAid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 pAddStaParams->enableAmpduPs = psessionEntry->enableAmpduPs;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002915 pAddStaParams->enableHtSmps = (psessionEntry->enableHtSmps &&
2916 (!psessionEntry->supported_nss_1x1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 pAddStaParams->htSmpsconfig = psessionEntry->htSmpsvalue;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002918 pAddStaParams->send_smps_action =
2919 psessionEntry->send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920
2921 /* For Self STA get the LDPC capability from session i.e config.ini */
2922 pAddStaParams->htLdpcCapable =
2923 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2924 pAddStaParams->vhtLdpcCapable =
2925 ((psessionEntry->txLdpcIniFeatureEnabled >> 1) & 0x01);
2926
2927 if (wlan_cfg_get_int(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) !=
2928 eSIR_SUCCESS)
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002929 pe_err("Couldn't get LISTEN_INTERVAL");
2930
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 pAddStaParams->listenInterval = (uint16_t) listenInterval;
2932
Anurag Chouhan6d760662016-02-20 16:05:43 +05302933 if (QDF_P2P_CLIENT_MODE == psessionEntry->pePersona) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 pAddStaParams->p2pCapableSta = 1;
2935 }
2936
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002937 pe_debug(" StaIdx: %d updateSta = %d htcapable = %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 pAddStaParams->staIdx, pAddStaParams->updateSta,
2939 pAddStaParams->htCapable);
2940
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002941 pe_debug("htLdpcCapable: %d vhtLdpcCapable: %d "
2942 "p2pCapableSta: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 pAddStaParams->htLdpcCapable, pAddStaParams->vhtLdpcCapable,
2944 pAddStaParams->p2pCapableSta);
2945
2946 if (psessionEntry->isNonRoamReassoc) {
2947 pAddStaParams->nonRoamReassoc = 1;
2948 psessionEntry->isNonRoamReassoc = 0;
2949 }
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002950 pe_debug("sessionid: %d Assoc ID: %d listenInterval = %d "
2951 "shortPreambleSupported: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 psessionEntry->smeSessionId, pAddStaParams->assocId,
2953 pAddStaParams->listenInterval,
2954 pAddStaParams->shortPreambleSupported);
2955
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002956 if (IS_DOT11_MODE_HE(selfStaDot11Mode))
2957 lim_add_self_he_cap(pAddStaParams, psessionEntry);
2958
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 msgQ.type = WMA_ADD_STA_REQ;
2960 msgQ.reserved = 0;
2961 msgQ.bodyptr = pAddStaParams;
2962 msgQ.bodyval = 0;
2963
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002964 pe_debug(MAC_ADDRESS_STR ":Sessionid %d : "
2965 "Sending WMA_ADD_STA_REQ. (aid %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 MAC_ADDR_ARRAY(pAddStaParams->staMac),
2967 pAddStaParams->sessionId, pAddStaParams->assocId);
2968 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
2969
2970 retCode = wma_post_ctrl_msg(pMac, &msgQ);
2971 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002972 pe_err("Posting WMA_ADD_STA_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302974 qdf_mem_free(pAddStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 }
2976 return retCode;
2977}
2978
2979/**
2980 * limTeardownInfraBSS()
2981 *
2982 ***FUNCTION:
2983 * This function is called by various LIM functions to teardown
2984 * an established Infrastructure BSS
2985 *
2986 ***LOGIC:
2987 *
2988 ***ASSUMPTIONS:
2989 *
2990 ***NOTE:
2991 *
2992 * @param pMac - Pointer to Global MAC structure
2993 * @return None
2994 */
2995
2996void lim_teardown_infra_bss(tpAniSirGlobal pMac, tpPESession psessionEntry)
2997{
2998 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
2999
3000 /**
3001 * Send Broadcast Disassociate frame with
3002 * 'leaving BSS' reason.
3003 */
3004 lim_send_disassoc_mgmt_frame(pMac,
3005 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
3006 bcAddr, psessionEntry, false);
3007} /*** end lim_teardown_infra_bss() ***/
3008
3009/**
3010 * lim_handle_cnf_wait_timeout()
3011 *
3012 ***FUNCTION:
3013 * This function is called by limProcessMessageQueue to handle
3014 * various confirmation failure cases.
3015 *
3016 ***LOGIC:
3017 *
3018 ***ASSUMPTIONS:
3019 *
3020 ***NOTE:
3021 *
3022 * @param pMac - Pointer to Global MAC structure
3023 * @param pStaDs - Pointer to a sta descriptor
3024 * @return None
3025 */
3026
3027void lim_handle_cnf_wait_timeout(tpAniSirGlobal pMac, uint16_t staId)
3028{
3029 tpDphHashNode pStaDs;
3030 tpPESession psessionEntry = NULL;
3031
3032 psessionEntry = pe_find_session_by_session_id(pMac,
3033 pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId);
3034 if (psessionEntry == NULL) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003035 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 return;
3037 }
3038 pStaDs = dph_get_hash_entry(pMac, staId, &psessionEntry->dph.dphHashTable);
3039
3040 if (pStaDs == NULL) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003041 pe_err("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 return;
3043 }
3044
3045 switch (pStaDs->mlmStaContext.mlmState) {
3046 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003047 pe_debug("Did not receive Assoc Cnf in eLIM_MLM_WT_ASSOC_CNF_STATE sta Assoc id %d",
3048 pStaDs->assocId);
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07003049 lim_print_mac_addr(pMac, pStaDs->staAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07003051 if (LIM_IS_AP_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 lim_reject_association(pMac, pStaDs->staAddr,
3053 pStaDs->mlmStaContext.subType,
3054 true,
3055 pStaDs->mlmStaContext.authType,
3056 pStaDs->assocId, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3058 psessionEntry);
3059 }
3060 break;
3061
3062 default:
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003063 pe_warn("Received CNF_WAIT_TIMEOUT in state %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 pStaDs->mlmStaContext.mlmState);
3065 }
3066}
3067
3068/**
3069 * lim_delete_dph_hash_entry()- function to delete dph hash entry
3070 * @mac_ctx: pointer to global mac structure
3071 * @sta_addr: peer station address
3072 * @sta_id: id assigned to peer station
3073 * @session_entry: pe session entry
3074 *
3075 * This function is called whenever we need to delete
3076 * the dph hash entry
3077 *
3078 * Return: none
3079 */
3080
3081void
3082lim_delete_dph_hash_entry(tpAniSirGlobal mac_ctx, tSirMacAddr sta_addr,
3083 uint16_t sta_id, tpPESession session_entry)
3084{
3085 uint16_t aid;
3086 tpDphHashNode sta_ds;
3087 tUpdateBeaconParams beacon_params;
3088
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303089 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 beacon_params.paramChangeBitmap = 0;
3091 lim_deactivate_and_change_per_sta_id_timer(mac_ctx, eLIM_CNF_WAIT_TIMER,
3092 sta_id);
3093 if (NULL == session_entry) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003094 pe_err("NULL session_entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 return;
3096 }
3097
3098 beacon_params.bssIdx = session_entry->bssIdx;
3099 sta_ds = dph_lookup_hash_entry(mac_ctx, sta_addr, &aid,
3100 &session_entry->dph.dphHashTable);
3101
3102 if (sta_ds == NULL) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003103 pe_err("sta_ds is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 return;
3105 }
3106
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003107 pe_debug("Deleting DPH Hash entry for STAID: %X", sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108 /*
3109 * update the station count and perform associated actions
3110 * do this before deleting the dph hash entry
3111 */
3112 lim_util_count_sta_del(mac_ctx, sta_ds, session_entry);
3113
3114 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry)) {
3115 if (LIM_IS_AP_ROLE(session_entry)) {
3116 if (session_entry->gLimProtectionControl !=
3117 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
3118 lim_decide_ap_protection_on_delete(mac_ctx,
3119 sta_ds, &beacon_params, session_entry);
3120 }
3121
gaolez7bb1e742017-03-21 16:37:38 +08003122 if (sta_ds->non_ecsa_capable) {
3123 if (session_entry->lim_non_ecsa_cap_num == 0) {
3124 pe_debug("NonECSA sta 0, id %d is ecsa",
3125 sta_id);
3126 } else {
3127 session_entry->lim_non_ecsa_cap_num--;
3128 pe_debug("reducing the non ECSA num to %d",
3129 session_entry->lim_non_ecsa_cap_num);
3130 }
3131 }
3132
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 if (LIM_IS_IBSS_ROLE(session_entry))
3134 lim_ibss_decide_protection_on_delete(mac_ctx, sta_ds,
3135 &beacon_params, session_entry);
3136
3137 lim_decide_short_preamble(mac_ctx, sta_ds, &beacon_params,
3138 session_entry);
3139 lim_decide_short_slot(mac_ctx, sta_ds, &beacon_params,
3140 session_entry);
3141
3142 /* Send message to HAL about beacon parameter change. */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003143 pe_debug("param bitmap: %d", beacon_params.paramChangeBitmap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 if (beacon_params.paramChangeBitmap &&
3145 (false ==
3146 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
3147 sch_set_fixed_beacon_fields(mac_ctx, session_entry);
3148 lim_send_beacon_params(mac_ctx, &beacon_params,
3149 session_entry);
3150 }
Arif Hussain1513cb22018-01-05 19:56:31 -08003151
3152 lim_obss_send_detection_cfg(mac_ctx, session_entry, false);
3153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154#ifdef WLAN_FEATURE_11W
Krunal Sonia59e8a42017-11-19 09:00:56 -08003155 if (sta_ds->rmfEnabled) {
3156 pe_debug("delete pmf timer sta-idx:%d assoc-id:%d",
3157 sta_ds->staIndex, sta_ds->assocId);
3158 tx_timer_delete(&sta_ds->pmfSaQueryTimer);
3159 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160#endif
3161 }
3162
3163 if (dph_delete_hash_entry(mac_ctx, sta_addr, sta_id,
3164 &session_entry->dph.dphHashTable) != eSIR_SUCCESS)
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003165 pe_err("error deleting hash entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166}
3167
3168/**
3169 * lim_check_and_announce_join_success()- function to check if the received
3170 * Beacon/Probe Response is from the BSS that we're attempting to join.
3171 * @mac: pointer to global mac structure
3172 * @beacon_probe_rsp: pointer to reveived beacon/probe response frame
3173 * @header: pointer to received management frame header
3174 * @session_entry: pe session entry
3175 *
3176 * This function is called upon receiving Beacon/Probe Response
3177 * frame in WT_JOIN_BEACON_STATE to check if the received
3178 * Beacon/Probe Response is from the BSS that we're attempting
3179 * to join.
3180 * If the Beacon/Probe Response is indeed from the BSS we're
3181 * attempting to join, join success is sent to SME.
3182 *
3183 * Return: none
3184 */
3185
3186void
3187lim_check_and_announce_join_success(tpAniSirGlobal mac_ctx,
3188 tSirProbeRespBeacon *beacon_probe_rsp, tpSirMacMgmtHdr header,
3189 tpPESession session_entry)
3190{
3191 tSirMacSSid current_ssid;
3192 tLimMlmJoinCnf mlm_join_cnf;
3193 uint32_t val = 0;
3194 uint32_t *noa_duration_from_beacon = NULL;
3195 uint32_t *noa2_duration_from_beacon = NULL;
3196 uint32_t noa;
3197 uint32_t total_num_noa_desc = 0;
3198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303199 qdf_mem_copy(current_ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 session_entry->ssId.ssId, session_entry->ssId.length);
3201
3202 current_ssid.length = (uint8_t) session_entry->ssId.length;
3203
3204 /*
3205 * Check for SSID only in probe response. Beacons may not carry
3206 * SSID information in hidden SSID case
3207 */
3208 if (((SIR_MAC_MGMT_FRAME == header->fc.type) &&
3209 (SIR_MAC_MGMT_PROBE_RSP == header->fc.subType)) &&
3210 current_ssid.length &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303211 (qdf_mem_cmp((uint8_t *) &beacon_probe_rsp->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 (uint8_t *) &current_ssid,
3213 (uint8_t) (1 + current_ssid.length)))) {
3214 /*
3215 * Received SSID does not match with the one we've.
3216 * Ignore received Beacon frame
3217 */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003218 pe_debug("SSID received in Beacon does not match");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219#ifdef WLAN_DEBUG
3220 mac_ctx->lim.gLimBcnSSIDMismatchCnt++;
3221#endif
3222 return;
3223 }
3224
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07003225 if (!LIM_IS_STA_ROLE(session_entry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 return;
3227
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003228 pe_debug("Received Beacon/PR with matching BSSID:%pM PESessionID %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 session_entry->bssId, session_entry->peSessionId);
3230
3231 /* Deactivate Join Failure timer */
3232 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
3233 /* Deactivate Periodic Join timer */
3234 lim_deactivate_and_change_timer(mac_ctx,
3235 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
3236
Anurag Chouhan6d760662016-02-20 16:05:43 +05303237 if (QDF_P2P_CLIENT_MODE == session_entry->pePersona &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.present) {
3239
3240 noa_duration_from_beacon = (uint32_t *)
3241 (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3242
3243 if (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3244 total_num_noa_desc =
3245 beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.
3246 num_NoADesc / SIZE_OF_NOA_DESCRIPTOR;
3247
3248 noa = *noa_duration_from_beacon;
3249
3250 if (total_num_noa_desc > 1) {
3251 noa2_duration_from_beacon = (uint32_t *)
3252 (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.NoADesc +
3253 SIZE_OF_NOA_DESCRIPTOR + 1);
3254 noa += *noa2_duration_from_beacon;
3255 }
3256
3257 /*
3258 * If MAX Noa exceeds 3 secs we will consider only 3 secs to
3259 * avoid arbitary values in noa duration field
3260 */
3261 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ?
3262 MAX_NOA_PERIOD_IN_MICROSECS : noa;
3263 noa = noa / 1000; /* Convert to ms */
3264
3265 if (wlan_cfg_get_int(mac_ctx,
3266 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT, &val) ==
3267 eSIR_SUCCESS) {
3268 session_entry->defaultAuthFailureTimeout = val;
3269 cfg_set_int(mac_ctx,
3270 WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,
3271 val + noa);
3272 }
3273 } else {
3274 session_entry->defaultAuthFailureTimeout = 0;
3275 }
3276
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303277
3278 /*
3279 * Check if MBO Association disallowed subattr is present and post
3280 * failure status to LIM if present
3281 */
3282 if (!session_entry->ignore_assoc_disallowed &&
3283 beacon_probe_rsp->assoc_disallowed) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003284 pe_err("Connection fails due to assoc disallowed reason(%d):%pM PESessionID %d",
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303285 beacon_probe_rsp->assoc_disallowed_reason,
3286 session_entry->bssId,
3287 session_entry->peSessionId);
3288 mlm_join_cnf.resultCode = eSIR_SME_ASSOC_REFUSED;
3289 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3290 session_entry->limMlmState = eLIM_MLM_IDLE_STATE;
3291 mlm_join_cnf.sessionId = session_entry->peSessionId;
3292 if (session_entry->pLimMlmJoinReq) {
3293 qdf_mem_free(session_entry->pLimMlmJoinReq);
3294 session_entry->pLimMlmJoinReq = NULL;
3295 }
3296 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
3297 (uint32_t *) &mlm_join_cnf);
3298 return;
3299 }
3300
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 /* Update Beacon Interval at CFG database */
3302
3303 if (beacon_probe_rsp->HTCaps.present)
3304 lim_update_sta_run_time_ht_capability(mac_ctx,
3305 &beacon_probe_rsp->HTCaps);
3306 if (beacon_probe_rsp->HTInfo.present)
3307 lim_update_sta_run_time_ht_info(mac_ctx,
3308 &beacon_probe_rsp->HTInfo, session_entry);
3309 session_entry->limMlmState = eLIM_MLM_JOINED_STATE;
3310 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
3311 session_entry->peSessionId, eLIM_MLM_JOINED_STATE));
3312
3313 /*
3314 * update the capability info based on recently received beacon/probe
3315 * response frame
3316 */
3317 session_entry->limCurrentBssCaps =
3318 lim_get_u16((uint8_t *)&beacon_probe_rsp->capabilityInfo);
3319
3320 /*
3321 * Announce join success by sending
3322 * Join confirm to SME.
3323 */
3324 mlm_join_cnf.resultCode = eSIR_SME_SUCCESS;
3325 mlm_join_cnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3326 /* Update PE sessionId */
3327 mlm_join_cnf.sessionId = session_entry->peSessionId;
3328 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
3329 (uint32_t *) &mlm_join_cnf);
3330
Kiran Kumar Lokeredda60772017-05-24 18:45:26 -07003331 if ((IS_DOT11_MODE_VHT(session_entry->dot11mode)) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303332 beacon_probe_rsp->vendor_vht_ie.VHTCaps.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 session_entry->is_vendor_specific_vhtcaps = true;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07003334 session_entry->vendor_specific_vht_ie_sub_type =
3335 beacon_probe_rsp->vendor_vht_ie.sub_type;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003336 pe_debug("VHT caps are present in vendor specific IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 }
Nitesh Shah0ddd4f62016-05-27 10:07:32 +05303338
3339 /* Update HS 2.0 Information Element */
3340 if (beacon_probe_rsp->hs20vendor_ie.present) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003341 pe_debug("HS20 Indication Element Present, rel#:%u, id:%u",
Nitesh Shah0ddd4f62016-05-27 10:07:32 +05303342 beacon_probe_rsp->hs20vendor_ie.release_num,
3343 beacon_probe_rsp->hs20vendor_ie.hs_id_present);
3344 qdf_mem_copy(&session_entry->hs20vendor_ie,
3345 &beacon_probe_rsp->hs20vendor_ie,
3346 sizeof(tDot11fIEhs20vendor_ie) -
3347 sizeof(beacon_probe_rsp->hs20vendor_ie.hs_id));
3348 if (beacon_probe_rsp->hs20vendor_ie.hs_id_present)
3349 qdf_mem_copy(&session_entry->hs20vendor_ie.hs_id,
3350 &beacon_probe_rsp->hs20vendor_ie.hs_id,
3351 sizeof(beacon_probe_rsp->hs20vendor_ie.hs_id));
3352 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353}
3354
3355/**
3356 * lim_extract_ap_capabilities()
3357 *
3358 ***FUNCTION:
3359 * This function is called to extract all of the AP's capabilities
3360 * from the IEs received from it in Beacon/Probe Response frames
3361 *
3362 ***LOGIC:
3363 * This routine mimics the lim_extract_ap_capability() API. The difference here
3364 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3365 * left to the caller of this API to use this info as required
3366 *
3367 ***ASSUMPTIONS:
3368 * NA
3369 *
3370 ***NOTE:
3371 *
3372 * @param pMac Pointer to Global MAC structure
3373 * @param pIE Pointer to starting IE in Beacon/Probe Response
3374 * @param ieLen Length of all IEs combined
3375 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3376 * populated
3377 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3378 */
3379tSirRetStatus lim_extract_ap_capabilities(tpAniSirGlobal pMac,
3380 uint8_t *pIE,
3381 uint16_t ieLen,
3382 tpSirProbeRespBeacon beaconStruct)
3383{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303384 qdf_mem_set((uint8_t *) beaconStruct, sizeof(tSirProbeRespBeacon), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003386 pe_debug("lim_extract_ap_capabilities: The IE's being received are:");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07003387 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
3388 pIE, ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 /* Parse the Beacon IE's, Don't try to parse if we dont have anything in IE */
3390 if (ieLen > 0) {
3391 if (eSIR_SUCCESS !=
3392 sir_parse_beacon_ie(pMac, beaconStruct, pIE,
3393 (uint32_t) ieLen)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003394 pe_err("APCapExtract: Beacon parsing error!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 return eSIR_FAILURE;
3396 }
3397 }
3398
3399 return eSIR_SUCCESS;
3400}
3401
3402/**
3403 * lim_del_bss()
3404 *
3405 ***FUNCTION:
3406 * This function is called to delete BSS context at hardware
3407 * whenever a STA is disassociated
3408 *
3409 ***LOGIC:
3410 *
3411 ***ASSUMPTIONS:
3412 * NA
3413 *
3414 ***NOTE:
3415 * NA
3416 *
3417 * @param pMac - Pointer to Global MAC structure
3418 * @param pStaDs - Pointer to the STA datastructure created by
3419 * LIM and maintained by DPH
3420 * @return retCode - Indicates success or failure return code
3421 */
3422
3423tSirRetStatus
3424lim_del_bss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, uint16_t bssIdx,
3425 tpPESession psessionEntry)
3426{
3427 tpDeleteBssParams pDelBssParams = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003428 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 tSirRetStatus retCode = eSIR_SUCCESS;
3430
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303431 pDelBssParams = qdf_mem_malloc(sizeof(tDeleteBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 if (NULL == pDelBssParams) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003433 pe_err("Unable to allocate memory during ADD_BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 return eSIR_MEM_ALLOC_FAILED;
3435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
3437 pDelBssParams->sessionId = psessionEntry->peSessionId; /* update PE session Id */
3438
3439 /* DPH was storing the AssocID in staID field, */
3440 /* staID is actually assigned by HAL when AddSTA message is sent. */
3441 if (pStaDs != NULL) {
3442 pDelBssParams->bssIdx = pStaDs->bssId;
3443 pStaDs->valid = 0;
3444 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3445 } else
3446 pDelBssParams->bssIdx = bssIdx;
3447 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3448 MTRACE(mac_trace
3449 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
3450 eLIM_MLM_WT_DEL_BSS_RSP_STATE));
3451
3452 if ((psessionEntry->peSessionId ==
3453 pMac->lim.limTimers.gLimJoinFailureTimer.sessionId)
3454 && (true ==
3455 tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer))) {
3456 lim_deactivate_and_change_timer(pMac, eLIM_JOIN_FAIL_TIMER);
3457 }
3458
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303459 pDelBssParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 pDelBssParams->respReqd = 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303461 qdf_mem_copy(pDelBssParams->bssid, psessionEntry->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 sizeof(tSirMacAddr));
3463 pDelBssParams->smesessionId = psessionEntry->smeSessionId;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003464 pe_debug("Sessionid %d : Sending HAL_DELETE_BSS_REQ "
3465 "for bss idx: %X BSSID:" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 pDelBssParams->sessionId, pDelBssParams->bssIdx,
3467 MAC_ADDR_ARRAY(psessionEntry->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 /* we need to defer the message until we get the response back from HAL. */
3469 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3470
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003471 pe_debug("process_ho_fail = %d", psessionEntry->process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07003472 if (psessionEntry->process_ho_fail)
3473 msgQ.type = WMA_DELETE_BSS_HO_FAIL_REQ;
3474 else
3475 msgQ.type = WMA_DELETE_BSS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 msgQ.reserved = 0;
3477 msgQ.bodyptr = pDelBssParams;
3478 msgQ.bodyval = 0;
3479
3480 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
3481
3482 retCode = wma_post_ctrl_msg(pMac, &msgQ);
3483 if (eSIR_SUCCESS != retCode) {
3484 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003485 pe_err("Posting DELETE_BSS_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303487 qdf_mem_free(pDelBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 }
3489
3490 return retCode;
3491}
3492
3493/**
3494 * lim_update_vhtcaps_assoc_resp : Update VHT caps in assoc response.
3495 * @mac_ctx Pointer to Global MAC structure
3496 * @pAddBssParams: parameters required for add bss params.
3497 * @vht_caps: VHT capabilities.
3498 * @psessionEntry : session entry.
3499 *
3500 * Return : void
3501 */
Jeff Johnson72c8e7c2016-10-06 18:43:52 -07003502static void lim_update_vhtcaps_assoc_resp(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 tpAddBssParams pAddBssParams,
3504 tDot11fIEVHTCaps *vht_caps, tpPESession psessionEntry)
3505{
3506 pAddBssParams->staContext.vht_caps =
3507 ((vht_caps->maxMPDULen <<
3508 SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
3509 (vht_caps->supportedChannelWidthSet <<
3510 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
3511 (vht_caps->ldpcCodingCap <<
3512 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
3513 (vht_caps->shortGI80MHz <<
3514 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
3515 (vht_caps->shortGI160and80plus80MHz <<
3516 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
3517 (vht_caps->txSTBC <<
3518 SIR_MAC_VHT_CAP_TXSTBC) |
3519 (vht_caps->rxSTBC <<
3520 SIR_MAC_VHT_CAP_RXSTBC) |
3521 (vht_caps->suBeamFormerCap <<
3522 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
3523 (vht_caps->suBeamformeeCap <<
3524 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
3525 (vht_caps->csnofBeamformerAntSup <<
3526 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
3527 (vht_caps->numSoundingDim <<
3528 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
3529 (vht_caps->muBeamformerCap <<
3530 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
3531 (vht_caps->muBeamformeeCap <<
3532 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
3533 (vht_caps->vhtTXOPPS <<
3534 SIR_MAC_VHT_CAP_TXOPPS) |
3535 (vht_caps->htcVHTCap <<
3536 SIR_MAC_VHT_CAP_HTC_CAP) |
3537 (vht_caps->maxAMPDULenExp <<
3538 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
3539 (vht_caps->vhtLinkAdaptCap <<
3540 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
3541 (vht_caps->rxAntPattern <<
3542 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
3543 (vht_caps->txAntPattern <<
3544 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
3545 (vht_caps->reserved1 <<
3546 SIR_MAC_VHT_CAP_RESERVED2));
3547
3548 pAddBssParams->staContext.maxAmpduSize =
3549 SIR_MAC_GET_VHT_MAX_AMPDU_EXPO(
3550 pAddBssParams->staContext.vht_caps);
3551
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003552 pe_debug("Updating VHT caps in assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553}
3554
3555/**
3556 * lim_update_vht_oper_assoc_resp : Update VHT Operations in assoc response.
3557 * @mac_ctx Pointer to Global MAC structure
3558 * @pAddBssParams: parameters required for add bss params.
3559 * @vht_oper: VHT Operations to update.
3560 * @psessionEntry : session entry.
3561 *
3562 * Return : void
3563 */
Jeff Johnson72c8e7c2016-10-06 18:43:52 -07003564static void lim_update_vht_oper_assoc_resp(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 tpAddBssParams pAddBssParams,
3566 tDot11fIEVHTOperation *vht_oper, tpPESession psessionEntry)
3567{
3568 if (vht_oper->chanWidth &&
3569 psessionEntry->ch_width) {
3570 pAddBssParams->ch_width = vht_oper->chanWidth + 1;
3571
3572 pAddBssParams->ch_center_freq_seg0 =
3573 vht_oper->chanCenterFreqSeg1;
3574
3575 pAddBssParams->ch_center_freq_seg1 =
3576 vht_oper->chanCenterFreqSeg2;
3577 }
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003578 pe_debug("Updating VHT Operation in assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579}
3580
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581/**
3582 * limSendAddBss()
3583 *
3584 ***FUNCTION:
3585 *
3586 ***LOGIC:
3587 * 1) LIM receives eWNI_SME_JOIN_REQ
3588 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3589 * SIR_HAL_ADD_BSS_REQ to HAL
3590 *
3591 ***ASSUMPTIONS:
3592 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3593 * ADD BSS parameters can be obtained from two sources:
3594 * 1) pMac->lim.gLimMlmJoinReq
3595 * 2) beaconStruct, passed as paramter
3596 * So, if a reqd parameter is found in bssDescriptions
3597 * then it is given preference over beaconStruct
3598 *
3599 ***NOTE:
3600 *
3601 * @param pMac Pointer to Global MAC structure
3602 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3603 * beaconstruct Has the ProbeRsp/Beacon structured details
3604 * bssDescription bssDescription passed to PE from the SME
3605 * @return None
3606 */
3607
3608tSirRetStatus lim_sta_send_add_bss(tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3609 tpSchBeaconStruct pBeaconStruct,
3610 tpSirBssDescription bssDescription,
3611 uint8_t updateEntry, tpPESession psessionEntry)
3612{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003613 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 tpAddBssParams pAddBssParams = NULL;
3615 uint32_t retCode;
3616 tpDphHashNode pStaDs = NULL;
3617 uint8_t chanWidthSupp = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 uint32_t enableTxBF20MHz;
3619 tDot11fIEVHTCaps *vht_caps = NULL;
3620 tDot11fIEVHTOperation *vht_oper = NULL;
3621 tAddStaParams *sta_context;
Krunal Sonib3f45422017-07-24 18:59:45 -07003622 uint32_t listen_interval = WNI_CFG_LISTEN_INTERVAL_STADEF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623
3624 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303625 pAddBssParams = qdf_mem_malloc(sizeof(tAddBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626 if (NULL == pAddBssParams) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003627 pe_err("Unable to allocate memory during ADD_BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 retCode = eSIR_MEM_ALLOC_FAILED;
3629 goto returnFailure;
Selvaraj, Sridhar6a8dcdf2016-10-19 15:53:58 +05303630 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303632 qdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 sizeof(tSirMacAddr));
3634 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303635 qdf_mem_copy(pAddBssParams->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
3637
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003638 pe_debug("sessionid: %d updateEntry: %d limsystemrole: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 psessionEntry->smeSessionId, updateEntry,
3640 GET_LIM_SYSTEM_ROLE(psessionEntry));
3641
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003642 pe_debug("BSSID: " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pAddBssParams->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07003644 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645
3646 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3647
3648 /* Update PE session ID */
3649 pAddBssParams->sessionId = psessionEntry->peSessionId;
3650
3651 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3652
3653 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3654 pAddBssParams->updateBss = updateEntry;
3655
3656 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3657 pAddBssParams->cfParamSet.cfpPeriod =
3658 pBeaconStruct->cfParamSet.cfpPeriod;
3659 pAddBssParams->cfParamSet.cfpMaxDuration =
3660 pBeaconStruct->cfParamSet.cfpMaxDuration;
3661 pAddBssParams->cfParamSet.cfpDurRemaining =
3662 pBeaconStruct->cfParamSet.cfpDurRemaining;
3663
3664 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303665 qdf_mem_copy(pAddBssParams->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 pAssocRsp->supportedRates.rate,
3667 pAssocRsp->supportedRates.numRates);
3668
3669 if (IS_DOT11_MODE_11B(psessionEntry->dot11mode) &&
3670 bssDescription->nwType != eSIR_11B_NW_TYPE) {
3671 pAddBssParams->nwType = eSIR_11B_NW_TYPE;
3672 } else {
3673 pAddBssParams->nwType = bssDescription->nwType;
3674 }
3675
3676 pAddBssParams->shortSlotTimeSupported =
3677 (uint8_t) pAssocRsp->capabilityInfo.shortSlotTime;
3678 pAddBssParams->llaCoexist =
3679 (uint8_t) psessionEntry->beaconParams.llaCoexist;
3680 pAddBssParams->llbCoexist =
3681 (uint8_t) psessionEntry->beaconParams.llbCoexist;
3682 pAddBssParams->llgCoexist =
3683 (uint8_t) psessionEntry->beaconParams.llgCoexist;
3684 pAddBssParams->ht20Coexist =
3685 (uint8_t) psessionEntry->beaconParams.ht20Coexist;
3686
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003687 pe_debug("BSS Type %d Beacon Interval: %d dtimPeriod: %d "
3688 "cfpCount: %d", pAddBssParams->bssType,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 pAddBssParams->beaconInterval, pAddBssParams->dtimPeriod,
3690 pAddBssParams->cfParamSet.cfpCount);
3691
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003692 pe_debug("cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining: %d "
3693 "numRates: %d", pAddBssParams->cfParamSet.cfpPeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694 pAddBssParams->cfParamSet.cfpMaxDuration,
3695 pAddBssParams->cfParamSet.cfpDurRemaining,
3696 pAddBssParams->rateSet.numRates);
3697
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003698 pe_debug("nwType:%d shortSlotTimeSupported: %d llaCoexist: %d "
3699 "llbCoexist: %d llgCoexist: %d ht20Coexist: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
3701 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
3702 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
3703
3704 pAddBssParams->dot11_mode = psessionEntry->dot11mode;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003705 pe_debug("dot11_mode: %d", pAddBssParams->dot11_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706
3707 /* Use the advertised capabilities from the received beacon/PR */
3708
3709 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
3710 && (pAssocRsp->HTCaps.present)) {
3711 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003712 pe_debug("htCapable: %d", pAddBssParams->htCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 if (pBeaconStruct->HTInfo.present) {
3714 pAddBssParams->htOperMode =
3715 (tSirMacHTOperatingMode) pAssocRsp->HTInfo.opMode;
3716 pAddBssParams->dualCTSProtection =
3717 (uint8_t) pAssocRsp->HTInfo.dualCTSProtection;
3718 chanWidthSupp =
3719 lim_get_ht_capability(pMac,
3720 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
3721 psessionEntry);
3722 if ((pAssocRsp->HTCaps.supportedChannelWidthSet)
3723 && (chanWidthSupp)) {
3724 pAddBssParams->ch_width = (uint8_t)
3725 pAssocRsp->HTInfo.recommendedTxWidthSet;
3726 if (pAssocRsp->HTInfo.secondaryChannelOffset ==
3727 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
3728 pAddBssParams->ch_center_freq_seg0 =
3729 bssDescription->channelId + 2;
3730 else if (pAssocRsp->HTInfo.secondaryChannelOffset ==
3731 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
3732 pAddBssParams->ch_center_freq_seg0 =
3733 bssDescription->channelId - 2;
3734 } else {
3735 pAddBssParams->ch_width = CH_WIDTH_20MHZ;
3736 pAddBssParams->ch_center_freq_seg0 = 0;
3737 }
3738 pAddBssParams->llnNonGFCoexist =
3739 (uint8_t) pAssocRsp->HTInfo.nonGFDevicesPresent;
3740 pAddBssParams->fLsigTXOPProtectionFullSupport =
3741 (uint8_t) pAssocRsp->HTInfo.
3742 lsigTXOPProtectionFullSupport;
3743 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
3744
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003745 pe_debug("htOperMode: %d dualCTSProtection: %d txChannelWidth: %d center_freq_0: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746 pAddBssParams->htOperMode,
3747 pAddBssParams->dualCTSProtection,
3748 pAddBssParams->ch_width,
3749 pAddBssParams->ch_center_freq_seg0);
3750
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003751 pe_debug("llnNonGFCoexist: %d "
3752 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753 pAddBssParams->llnNonGFCoexist,
3754 pAddBssParams->fLsigTXOPProtectionFullSupport,
3755 pAddBssParams->fRIFSMode);
3756 }
3757 }
3758
3759 pAddBssParams->currentOperChannel = bssDescription->channelId;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003760 pe_debug("currentOperChannel %d", pAddBssParams->currentOperChannel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761 if (psessionEntry->vhtCapability && (pAssocRsp->VHTCaps.present)) {
3762 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3763 vht_caps = &pAssocRsp->VHTCaps;
3764 vht_oper = &pAssocRsp->VHTOperation;
3765 } else if (psessionEntry->vhtCapability &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303766 pAssocRsp->vendor_vht_ie.VHTCaps.present){
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767 pAddBssParams->vhtCapable =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303768 pAssocRsp->vendor_vht_ie.VHTCaps.present;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003769 pe_debug("VHT Caps and Operation are present in vendor Specfic IE");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303770 vht_caps = &pAssocRsp->vendor_vht_ie.VHTCaps;
3771 vht_oper = &pAssocRsp->vendor_vht_ie.VHTOperation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 } else {
3773 pAddBssParams->vhtCapable = 0;
3774 }
3775 if (pAddBssParams->vhtCapable) {
3776 if (vht_oper != NULL)
3777 lim_update_vht_oper_assoc_resp(pMac, pAddBssParams,
3778 vht_oper, psessionEntry);
3779 if (vht_caps != NULL)
3780 lim_update_vhtcaps_assoc_resp(pMac, pAddBssParams,
3781 vht_caps, psessionEntry);
3782 }
3783
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003784 pe_debug("vhtCapable %d TxChannelWidth %d center_freq_0 %d center_freq_1 %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 pAddBssParams->vhtCapable, pAddBssParams->ch_width,
3786 pAddBssParams->ch_center_freq_seg0,
3787 pAddBssParams->ch_center_freq_seg1);
3788
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08003789 if (lim_is_session_he_capable(psessionEntry) &&
Naveen Rawatd8feac12017-09-08 15:08:39 -07003790 (pAssocRsp->he_cap.present)) {
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08003791 lim_add_bss_he_cap(pAddBssParams, pAssocRsp);
Manikandan Mohan39accff2017-05-02 16:09:00 -07003792 lim_add_bss_he_cfg(pAddBssParams, psessionEntry);
3793 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794 /*
3795 * Populate the STA-related parameters here
3796 * Note that the STA here refers to the AP
3797 * staType = PEER
3798 */
3799 sta_context = &pAddBssParams->staContext;
3800 /* Identifying AP as an STA */
3801 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
3802
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303803 qdf_mem_copy(pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 bssDescription->bssId, sizeof(tSirMacAddr));
Krunal Sonib3f45422017-07-24 18:59:45 -07003805 if (wlan_cfg_get_int(pMac, WNI_CFG_LISTEN_INTERVAL, &listen_interval) !=
3806 eSIR_SUCCESS)
3807 pe_err("Couldn't get LISTEN_INTERVAL");
3808 pAddBssParams->staContext.listenInterval = listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809
3810 /* Fill Assoc id from the dph table */
3811 pStaDs = dph_lookup_hash_entry(pMac, pAddBssParams->staContext.bssId,
3812 &pAddBssParams->staContext.assocId,
3813 &psessionEntry->dph.dphHashTable);
3814 if (pStaDs == NULL) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003815 pe_err("Couldn't get assoc id for " "MAC ADDR: "
3816 MAC_ADDRESS_STR,
3817 MAC_ADDR_ARRAY(
3818 pAddBssParams->staContext.staMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 return eSIR_FAILURE;
3820 }
3821
3822 pAddBssParams->staContext.uAPSD =
3823 psessionEntry->gUapsdPerAcBitmask;
3824
3825 pAddBssParams->staContext.maxSPLen = 0;
3826 pAddBssParams->staContext.shortPreambleSupported =
3827 (uint8_t) pAssocRsp->capabilityInfo.shortPreamble;
3828 pAddBssParams->staContext.updateSta = updateEntry;
3829
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003830 pe_debug("StaContext: " MAC_ADDRESS_STR
3831 " shortPreambleSupported: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
3833 pAddBssParams->staContext.shortPreambleSupported);
3834
3835 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
3836 && pBeaconStruct->HTCaps.present) {
3837 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3838 pAddBssParams->staContext.htCapable = 1;
3839 pAddBssParams->staContext.greenFieldCapable =
3840 (uint8_t) pAssocRsp->HTCaps.greenField;
3841 pAddBssParams->staContext.lsigTxopProtection =
3842 (uint8_t) pAssocRsp->HTCaps.lsigTXOPProtection;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003843 pe_debug("StaCtx: htCap %d GFcap %d lsigTxopProtn %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844 pAddBssParams->staContext.htCapable,
3845 pAddBssParams->staContext.greenFieldCapable,
3846 pAddBssParams->staContext.lsigTxopProtection);
Arif Hussain53cf5692018-04-05 16:35:54 -07003847 if (psessionEntry->htConfig.ht_tx_stbc)
3848 pAddBssParams->staContext.stbc_capable =
3849 pAssocRsp->HTCaps.rxSTBC;
3850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 if (psessionEntry->vhtCapability &&
3852 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303853 IS_BSS_VHT_CAPABLE(pBeaconStruct->
3854 vendor_vht_ie.VHTCaps))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 pAddBssParams->staContext.vhtCapable = 1;
3856 pAddBssParams->staContext.vhtSupportedRxNss =
3857 pStaDs->vhtSupportedRxNss;
3858 if (pAssocRsp->VHTCaps.present)
3859 vht_caps = &pAssocRsp->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303860 else if (pAssocRsp->vendor_vht_ie.VHTCaps.present) {
3861 vht_caps = &pAssocRsp->vendor_vht_ie.VHTCaps;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003862 pe_debug("VHT Caps are in vendor Specfic IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 }
3864
3865 if ((vht_caps != NULL) && (vht_caps->suBeamFormerCap ||
Krunal Soni53993f72016-07-08 18:20:03 -07003866 vht_caps->muBeamformerCap) &&
3867 psessionEntry->vht_config.su_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 sta_context->vhtTxBFCapable = 1;
3869
3870 if ((vht_caps != NULL) && vht_caps->muBeamformerCap &&
Krunal Soni53993f72016-07-08 18:20:03 -07003871 psessionEntry->vht_config.mu_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 sta_context->vhtTxMUBformeeCapable = 1;
Krunal Soni53993f72016-07-08 18:20:03 -07003873
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 if ((vht_caps != NULL) && vht_caps->suBeamformeeCap &&
Krunal Soni53993f72016-07-08 18:20:03 -07003875 psessionEntry->vht_config.su_beam_former)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 sta_context->enable_su_tx_bformer = 1;
Arif Hussain53cf5692018-04-05 16:35:54 -07003877
3878 if (vht_caps && pAddBssParams->staContext.stbc_capable)
3879 pAddBssParams->staContext.stbc_capable =
3880 vht_caps->rxSTBC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08003882 if (lim_is_session_he_capable(psessionEntry) &&
Arif Hussain53cf5692018-04-05 16:35:54 -07003883 pAssocRsp->he_cap.present) {
3884 lim_intersect_ap_he_caps(psessionEntry,
3885 pAddBssParams,
3886 NULL,
3887 pAssocRsp);
3888 lim_update_he_stbc_capable(&pAddBssParams->staContext);
3889 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890
3891 if ((pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3892 (chanWidthSupp)) {
3893 pAddBssParams->staContext.ch_width = (uint8_t)
3894 pAssocRsp->HTInfo.recommendedTxWidthSet;
3895 if (pAssocRsp->VHTCaps.present)
3896 vht_oper = &pAssocRsp->VHTOperation;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303897 else if (pAssocRsp->vendor_vht_ie.VHTCaps.present) {
3898 vht_oper = &pAssocRsp->
3899 vendor_vht_ie.VHTOperation;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003900 pe_debug("VHT Op IE is in vendor Specfic IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 }
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08003902 /*
3903 * in limExtractApCapability function intersection of FW
3904 * advertised channel width and AP advertised channel
3905 * width has been taken into account for calculating
3906 * psessionEntry->ch_width
3907 */
3908 pAddBssParams->staContext.ch_width =
3909 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003911 pe_debug("StaCtx: vhtCap %d ChBW %d TxBF %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 pAddBssParams->staContext.vhtCapable,
3913 pAddBssParams->staContext.ch_width,
3914 sta_context->vhtTxBFCapable);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003915 pe_debug("StaContext su_tx_bfer %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 sta_context->enable_su_tx_bformer);
3917 } else {
3918 sta_context->ch_width = CH_WIDTH_20MHZ;
3919 if ((IS_SIR_STATUS_SUCCESS(
3920 wlan_cfg_get_int(pMac,
3921 WNI_CFG_VHT_ENABLE_TXBF_20MHZ,
3922 &enableTxBF20MHz))) &&
3923 (false == enableTxBF20MHz))
3924 sta_context->vhtTxBFCapable = 0;
3925 }
3926 pAddBssParams->staContext.mimoPS =
3927 (tSirMacHTMIMOPowerSaveState)
3928 pAssocRsp->HTCaps.mimoPowerSave;
3929 pAddBssParams->staContext.maxAmsduSize =
3930 (uint8_t) pAssocRsp->HTCaps.maximalAMSDUsize;
3931 pAddBssParams->staContext.maxAmpduDensity =
3932 pAssocRsp->HTCaps.mpduDensity;
3933 pAddBssParams->staContext.fDsssCckMode40Mhz =
3934 (uint8_t) pAssocRsp->HTCaps.dsssCckMode40MHz;
3935 /*
3936 * We will check gShortGI20Mhz and gShortGI40Mhz from
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003937 * session entry if they are set then we will use what ever
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003938 * Assoc response coming from AP supports. If these
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003939 * values are set as 0 in session entry then we will
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 * hardcode this values to 0.
3941 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003942 if (psessionEntry->htConfig.ht_sgi20) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943 pAddBssParams->staContext.fShortGI20Mhz =
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003944 (uint8_t)pAssocRsp->HTCaps.shortGI20MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945 } else {
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003946 pAddBssParams->staContext.fShortGI20Mhz = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 }
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003948
3949 if (psessionEntry->htConfig.ht_sgi40) {
3950 pAddBssParams->staContext.fShortGI40Mhz =
3951 (uint8_t) pAssocRsp->HTCaps.shortGI40MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952 } else {
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003953 pAddBssParams->staContext.fShortGI40Mhz = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954 }
3955
3956 if (!pAddBssParams->staContext.vhtCapable)
3957 /* Use max ampd factor advertised in
3958 * HTCAP for non-vht connection */
3959 {
3960 pAddBssParams->staContext.maxAmpduSize =
3961 pAssocRsp->HTCaps.maxRxAMPDUFactor;
3962 } else if (pAddBssParams->staContext.maxAmpduSize <
3963 pAssocRsp->HTCaps.maxRxAMPDUFactor) {
3964 pAddBssParams->staContext.maxAmpduSize =
3965 pAssocRsp->HTCaps.maxRxAMPDUFactor;
3966 }
3967 if (pAddBssParams->staContext.vhtTxBFCapable
3968 && pMac->lim.disableLDPCWithTxbfAP) {
3969 pAddBssParams->staContext.htLdpcCapable = 0;
3970 pAddBssParams->staContext.vhtLdpcCapable = 0;
3971 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003972 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
3973 pAddBssParams->staContext.htLdpcCapable =
3974 (uint8_t) pAssocRsp->HTCaps.advCodingCap;
3975 else
3976 pAddBssParams->staContext.htLdpcCapable = 0;
3977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 if (pAssocRsp->VHTCaps.present)
3979 vht_caps = &pAssocRsp->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303980 else if (pAssocRsp->vendor_vht_ie.VHTCaps.present) {
3981 vht_caps = &pAssocRsp->vendor_vht_ie.VHTCaps;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003982 pe_debug("VHT Caps is in vendor Specfic IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 }
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003984 if (vht_caps != NULL &&
3985 (psessionEntry->txLdpcIniFeatureEnabled & 0x2))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 pAddBssParams->staContext.vhtLdpcCapable =
3987 (uint8_t) vht_caps->ldpcCodingCap;
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003988 else
3989 pAddBssParams->staContext.vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 }
3991
3992 if (pBeaconStruct->HTInfo.present)
3993 pAddBssParams->staContext.rifsMode =
3994 pAssocRsp->HTInfo.rifsMode;
3995
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003996 pe_debug("StaCtx: ChBW %d mimoPS %d maxAmsduSize %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 pAddBssParams->staContext.ch_width,
3998 pAddBssParams->staContext.mimoPS,
3999 pAddBssParams->staContext.maxAmsduSize);
4000
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004001 pe_debug("maxAmpduDens %d CckMode40Mhz %d SGI20Mhz %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002 pAddBssParams->staContext.maxAmpduDensity,
4003 pAddBssParams->staContext.fDsssCckMode40Mhz,
4004 pAddBssParams->staContext.fShortGI20Mhz);
4005
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004006 pe_debug("SGI40M %d maxAmpdu %d htLdpc %d vhtLdpc %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 pAddBssParams->staContext.fShortGI40Mhz,
4008 pAddBssParams->staContext.maxAmpduSize,
4009 pAddBssParams->staContext.htLdpcCapable,
4010 pAddBssParams->staContext.vhtLdpcCapable);
4011 }
4012 pAddBssParams->staContext.smesessionId =
4013 psessionEntry->smeSessionId;
4014 pAddBssParams->staContext.wpa_rsn = pBeaconStruct->rsnPresent;
4015 pAddBssParams->staContext.wpa_rsn |=
4016 (pBeaconStruct->wpaPresent << 1);
4017 /* For OSEN Connection AP does not advertise RSN or WPA IE
4018 * so from the IEs we get from supplicant we get this info
4019 * so for FW to transmit EAPOL message 4 we shall set
4020 * wpa_rsn
4021 */
4022 if ((!pAddBssParams->staContext.wpa_rsn)
4023 && (psessionEntry->isOSENConnection))
4024 pAddBssParams->staContext.wpa_rsn = 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304025 qdf_mem_copy(&pAddBssParams->staContext.capab_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 &pAssocRsp->capabilityInfo,
4027 sizeof(pAddBssParams->staContext.capab_info));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304028 qdf_mem_copy(&pAddBssParams->staContext.ht_caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 (uint8_t *) &pAssocRsp->HTCaps + sizeof(uint8_t),
4030 sizeof(pAddBssParams->staContext.ht_caps));
4031
4032 /* If WMM IE or 802.11E IE is present then enable WMM */
4033 if ((psessionEntry->limWmeEnabled && pAssocRsp->wmeEdcaPresent) ||
4034 (psessionEntry->limQosEnabled && pAssocRsp->edcaPresent))
4035 pAddBssParams->staContext.wmmEnabled = 1;
4036 else
4037 pAddBssParams->staContext.wmmEnabled = 0;
4038
4039 /* Update the rates */
4040 pStaDs = dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
4041 &psessionEntry->dph.dphHashTable);
4042 if (pStaDs != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304043 qdf_mem_copy((uint8_t *) &pAddBssParams->staContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 supportedRates,
Kiran Kumar Lokere5899f432016-02-18 12:53:42 -08004045 (uint8_t *)&pStaDs->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 sizeof(tSirSupportedRates));
4047 } else
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004048 pe_err("could not Update the supported rates");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004052 pe_debug("maxTxPower: %d", pAddBssParams->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 /* FIXME_GEN4 - Any other value that can be used for initialization? */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304054 pAddBssParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 pAddBssParams->respReqd = true;
4056 /* update persona */
4057 pAddBssParams->halPersona = (uint8_t) psessionEntry->pePersona;
4058
Anurag Chouhan6d760662016-02-20 16:05:43 +05304059 if (QDF_P2P_CLIENT_MODE == psessionEntry->pePersona)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 pAddBssParams->staContext.p2pCapableSta = 1;
4061
4062 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
4063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 pAddBssParams->extSetStaKeyParamValid = 0;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004065 pe_debug("extSetStaKeyParamValid: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 pAddBssParams->extSetStaKeyParamValid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067
4068#ifdef WLAN_FEATURE_11W
4069 if (psessionEntry->limRmfEnabled) {
4070 pAddBssParams->rmfEnabled = 1;
4071 pAddBssParams->staContext.rmfEnabled = 1;
4072 }
4073#endif
4074
4075 /* Set a new state for MLME */
4076 if (eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState)
4077 psessionEntry->limMlmState =
4078 eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
4079 else
4080 psessionEntry->limMlmState =
4081 eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
4082 MTRACE(mac_trace
4083 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
4084 psessionEntry->limMlmState));
4085
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004086 if (!pAddBssParams->staContext.htLdpcCapable)
4087 pAddBssParams->staContext.ht_caps &=
4088 ~(1 << SIR_MAC_HT_CAP_ADVCODING_S);
4089 if (!pAddBssParams->staContext.vhtLdpcCapable)
4090 pAddBssParams->staContext.vht_caps &=
4091 ~(1 << SIR_MAC_VHT_CAP_LDPC_CODING_CAP);
4092
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004093 pe_debug("staContext wmmEnabled: %d encryptType: %d "
4094 "p2pCapableSta: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 pAddBssParams->staContext.wmmEnabled,
4096 pAddBssParams->staContext.encryptType,
4097 pAddBssParams->staContext.p2pCapableSta);
4098
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004099 pe_debug("bSpectrumMgtEnabled: %d halPersona: %d setting "
4100 "LimMlm state to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 pAddBssParams->bSpectrumMgtEnabled, pAddBssParams->halPersona,
4102 psessionEntry->limMlmState);
4103 if (psessionEntry->isNonRoamReassoc)
4104 pAddBssParams->nonRoamReassoc = 1;
4105 pAddBssParams->nss = psessionEntry->nss;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004106 pe_debug("nss value: %d", pAddBssParams->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107
4108 /* we need to defer the message until we get the response back from HAL. */
4109 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4110
Naveen Rawat64e477e2016-05-20 10:34:56 -07004111 if (cds_is_5_mhz_enabled()) {
4112 pAddBssParams->ch_width = CH_WIDTH_5MHZ;
4113 pAddBssParams->staContext.ch_width = CH_WIDTH_5MHZ;
4114 } else if (cds_is_10_mhz_enabled()) {
4115 pAddBssParams->ch_width = CH_WIDTH_10MHZ;
4116 pAddBssParams->staContext.ch_width = CH_WIDTH_10MHZ;
4117 }
4118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 msgQ.type = WMA_ADD_BSS_REQ;
4120 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4121 msgQ.reserved = 0;
4122 msgQ.bodyptr = pAddBssParams;
4123 msgQ.bodyval = 0;
4124
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004125 pe_debug("SessionId: %d Sending WMA_ADD_BSS_REQ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 psessionEntry->peSessionId);
4127 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
4128
4129 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4130 if (eSIR_SUCCESS != retCode) {
4131 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304132 qdf_mem_free(pAddBssParams);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004133 pe_err("Posting ADD_BSS_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 retCode);
4135 goto returnFailure;
4136
4137 } else
4138 return retCode;
4139
4140returnFailure:
4141 /* Clean-up will be done by the caller... */
4142 return retCode;
4143}
4144
4145tSirRetStatus lim_sta_send_add_bss_pre_assoc(tpAniSirGlobal pMac, uint8_t updateEntry,
4146 tpPESession psessionEntry)
4147{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004148 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 tpAddBssParams pAddBssParams = NULL;
4150 uint32_t retCode;
4151 tSchBeaconStruct *pBeaconStruct;
4152 uint8_t chanWidthSupp = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 tDot11fIEVHTOperation *vht_oper = NULL;
4154 tDot11fIEVHTCaps *vht_caps = NULL;
Krunal Sonib3f45422017-07-24 18:59:45 -07004155 uint32_t listen_interval = WNI_CFG_LISTEN_INTERVAL_STADEF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156
4157 tpSirBssDescription bssDescription =
4158 &psessionEntry->pLimJoinReq->bssDescription;
4159
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304160 pBeaconStruct = qdf_mem_malloc(sizeof(tSchBeaconStruct));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 if (NULL == pBeaconStruct) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004162 pe_err("Unable to allocate memory during ADD_BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 return eSIR_MEM_ALLOC_FAILED;
4164 }
4165
4166 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304167 pAddBssParams = qdf_mem_malloc(sizeof(tAddBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 if (NULL == pAddBssParams) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004169 pe_err("Unable to allocate memory during ADD_BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 retCode = eSIR_MEM_ALLOC_FAILED;
4171 goto returnFailure;
4172 }
4173
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 lim_extract_ap_capabilities(pMac, (uint8_t *) bssDescription->ieFields,
4175 lim_get_ielen_from_bss_description(bssDescription),
4176 pBeaconStruct);
4177
4178 if (pMac->lim.gLimProtectionControl !=
4179 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
4180 lim_decide_sta_protection_on_assoc(pMac, pBeaconStruct,
4181 psessionEntry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304182 qdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 sizeof(tSirMacAddr));
4184
4185 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304186 qdf_mem_copy(pAddBssParams->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 psessionEntry->selfMacAddr, sizeof(tSirMacAddr));
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004188 pe_debug("sessionid: %d updateEntry = %d limsystemrole = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 psessionEntry->smeSessionId, updateEntry,
4190 GET_LIM_SYSTEM_ROLE(psessionEntry));
4191
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004192 pe_debug("BSSID: " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 MAC_ADDR_ARRAY(pAddBssParams->bssId));
4194 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
4195 * top of an already established Infra link. This lead to issues in
4196 * concurrent data transfer.
4197 */
4198
4199 pAddBssParams->bssType = psessionEntry->bssType; /* eSIR_INFRASTRUCTURE_MODE; */
4200 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
4201
4202 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
4203
4204 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
4205 pAddBssParams->updateBss = updateEntry;
4206
4207 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
4208 pAddBssParams->cfParamSet.cfpPeriod =
4209 pBeaconStruct->cfParamSet.cfpPeriod;
4210 pAddBssParams->cfParamSet.cfpMaxDuration =
4211 pBeaconStruct->cfParamSet.cfpMaxDuration;
4212 pAddBssParams->cfParamSet.cfpDurRemaining =
4213 pBeaconStruct->cfParamSet.cfpDurRemaining;
4214
4215 pAddBssParams->rateSet.numRates =
4216 pBeaconStruct->supportedRates.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304217 qdf_mem_copy(pAddBssParams->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 pBeaconStruct->supportedRates.rate,
4219 pBeaconStruct->supportedRates.numRates);
4220
4221 pAddBssParams->nwType = bssDescription->nwType;
4222
4223 pAddBssParams->shortSlotTimeSupported =
4224 (uint8_t) pBeaconStruct->capabilityInfo.shortSlotTime;
4225 pAddBssParams->llaCoexist =
4226 (uint8_t) psessionEntry->beaconParams.llaCoexist;
4227 pAddBssParams->llbCoexist =
4228 (uint8_t) psessionEntry->beaconParams.llbCoexist;
4229 pAddBssParams->llgCoexist =
4230 (uint8_t) psessionEntry->beaconParams.llgCoexist;
4231 pAddBssParams->ht20Coexist =
4232 (uint8_t) psessionEntry->beaconParams.ht20Coexist;
4233
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004234 pe_debug("BSS Type %d Beacon Interval: %d dtimPeriod: %d "
4235 "cfpCount: %d", pAddBssParams->bssType,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236 pAddBssParams->beaconInterval, pAddBssParams->dtimPeriod,
4237 pAddBssParams->cfParamSet.cfpCount);
4238
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004239 pe_debug("cfpPeriod: %d cfpMaxDuration: %d cfpDurRemaining: %d"
4240 " numRates: %d", pAddBssParams->cfParamSet.cfpPeriod,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 pAddBssParams->cfParamSet.cfpMaxDuration,
4242 pAddBssParams->cfParamSet.cfpDurRemaining,
4243 pAddBssParams->rateSet.numRates);
4244
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004245 pe_debug("nwType:%d shortSlotTimeSupported: %d"
4246 "llaCoexist: %d llbCoexist: %d llgCoexist: %d ht20Coexist: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 pAddBssParams->nwType, pAddBssParams->shortSlotTimeSupported,
4248 pAddBssParams->llaCoexist, pAddBssParams->llbCoexist,
4249 pAddBssParams->llgCoexist, pAddBssParams->ht20Coexist);
4250 /* Use the advertised capabilities from the received beacon/PR */
4251 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
4252 && (pBeaconStruct->HTCaps.present)) {
4253 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004254 pe_debug("htCapable: %d", pAddBssParams->htCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 if (pBeaconStruct->HTInfo.present) {
4256 pAddBssParams->htOperMode =
4257 (tSirMacHTOperatingMode) pBeaconStruct->HTInfo.
4258 opMode;
4259 pAddBssParams->dualCTSProtection =
4260 (uint8_t) pBeaconStruct->HTInfo.dualCTSProtection;
4261
4262 chanWidthSupp =
4263 lim_get_ht_capability(pMac,
4264 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
4265 psessionEntry);
4266 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet)
4267 && (chanWidthSupp)) {
4268 pAddBssParams->ch_width =
4269 (uint8_t) pBeaconStruct->HTInfo.
4270 recommendedTxWidthSet;
4271 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
4272 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
4273 pAddBssParams->ch_center_freq_seg0 =
4274 bssDescription->channelId + 2;
4275
4276 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
4277 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
4278 pAddBssParams->ch_center_freq_seg0 =
4279 bssDescription->channelId - 2;
4280 } else {
4281 pAddBssParams->ch_width = CH_WIDTH_20MHZ;
4282 pAddBssParams->ch_center_freq_seg0 = 0;
4283 }
4284 pAddBssParams->llnNonGFCoexist =
4285 (uint8_t) pBeaconStruct->HTInfo.nonGFDevicesPresent;
4286 pAddBssParams->fLsigTXOPProtectionFullSupport =
4287 (uint8_t) pBeaconStruct->HTInfo.
4288 lsigTXOPProtectionFullSupport;
4289 pAddBssParams->fRIFSMode =
4290 pBeaconStruct->HTInfo.rifsMode;
4291
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004292 pe_debug("htOperMode: %d dualCTSProtection: %d txChannelWidthSet: %d center_freq_seg0: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 pAddBssParams->htOperMode,
4294 pAddBssParams->dualCTSProtection,
4295 pAddBssParams->txChannelWidthSet,
4296 pAddBssParams->ch_center_freq_seg0);
4297
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004298 pe_debug("llnNonGFCoexist: %d "
4299 "fLsigTXOPProtectionFullSupport: %d fRIFSMode %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 pAddBssParams->llnNonGFCoexist,
4301 pAddBssParams->fLsigTXOPProtectionFullSupport,
4302 pAddBssParams->fRIFSMode);
4303 }
4304 }
4305
4306 pAddBssParams->currentOperChannel = bssDescription->channelId;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004307 pe_debug("currentOperChannel %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 pAddBssParams->currentOperChannel);
Kiran Kumar Lokeredda60772017-05-24 18:45:26 -07004309
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 if (psessionEntry->vhtCapability &&
4311 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05304312 IS_BSS_VHT_CAPABLE(pBeaconStruct->vendor_vht_ie.VHTCaps))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313
4314 pAddBssParams->vhtCapable = 1;
4315 if (pBeaconStruct->VHTOperation.present)
4316 vht_oper = &pBeaconStruct->VHTOperation;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05304317 else if (pBeaconStruct->vendor_vht_ie.VHTOperation.present) {
4318 vht_oper = &pBeaconStruct->vendor_vht_ie.VHTOperation;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004319 pe_debug("VHT Operation is present in vendor Specfic IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 }
4321
4322
4323 if ((vht_oper != NULL) &&
4324 vht_oper->chanWidth &&
4325 chanWidthSupp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326 pAddBssParams->ch_center_freq_seg0 =
4327 vht_oper->chanCenterFreqSeg1;
4328 pAddBssParams->ch_center_freq_seg1 =
4329 vht_oper->chanCenterFreqSeg2;
4330 }
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08004331 /*
4332 * in limExtractApCapability function intersection of FW
4333 * advertised channel width and AP advertised channel width has
4334 * been taken into account for calculating
4335 * psessionEntry->ch_width
4336 */
4337 pAddBssParams->ch_width =
4338 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 pAddBssParams->staContext.maxAmpduSize =
4340 SIR_MAC_GET_VHT_MAX_AMPDU_EXPO(
4341 pAddBssParams->staContext.vht_caps);
4342 } else {
4343 pAddBssParams->vhtCapable = 0;
4344 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08004345
4346 if (lim_is_session_he_capable(psessionEntry) &&
Naveen Rawatd8feac12017-09-08 15:08:39 -07004347 pBeaconStruct->he_cap.present) {
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08004348 lim_update_bss_he_capable(pMac, pAddBssParams);
Manikandan Mohan39accff2017-05-02 16:09:00 -07004349 lim_add_bss_he_cfg(pAddBssParams, psessionEntry);
4350 }
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004351 pe_debug("vhtCapable %d vhtTxChannelWidthSet %d center_freq_seg0 - %d, center_freq_seg1 - %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 pAddBssParams->vhtCapable, pAddBssParams->ch_width,
4353 pAddBssParams->ch_center_freq_seg0,
4354 pAddBssParams->ch_center_freq_seg1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355 /*
4356 * Populate the STA-related parameters here
4357 * Note that the STA here refers to the AP
4358 */
4359 /* Identifying AP as an STA */
4360 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
4361
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304362 qdf_mem_copy(pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363 bssDescription->bssId, sizeof(tSirMacAddr));
Krunal Sonib3f45422017-07-24 18:59:45 -07004364 if (wlan_cfg_get_int(pMac, WNI_CFG_LISTEN_INTERVAL, &listen_interval) !=
4365 eSIR_SUCCESS)
4366 pe_err("Couldn't get LISTEN_INTERVAL");
4367 pAddBssParams->staContext.listenInterval = listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368 pAddBssParams->staContext.assocId = 0;
4369 pAddBssParams->staContext.uAPSD = 0;
4370 pAddBssParams->staContext.maxSPLen = 0;
4371 pAddBssParams->staContext.shortPreambleSupported =
4372 (uint8_t) pBeaconStruct->capabilityInfo.shortPreamble;
4373 pAddBssParams->staContext.updateSta = updateEntry;
4374
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004375 pe_debug("StaCtx: " MAC_ADDRESS_STR " shortPreamble: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 MAC_ADDR_ARRAY(pAddBssParams->staContext.staMac),
4377 pAddBssParams->staContext.shortPreambleSupported);
4378
4379 pAddBssParams->dot11_mode = psessionEntry->dot11mode;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004380 pe_debug("dot11_mode:%d", pAddBssParams->dot11_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381
4382 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)
4383 && (pBeaconStruct->HTCaps.present)) {
4384 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
4385 pAddBssParams->staContext.htCapable = 1;
4386 pAddBssParams->staContext.greenFieldCapable =
4387 (uint8_t) pBeaconStruct->HTCaps.greenField;
4388 pAddBssParams->staContext.lsigTxopProtection =
4389 (uint8_t) pBeaconStruct->HTCaps.lsigTXOPProtection;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004390 pe_debug("StaCtx: htCap %d GFCap %d lsigTxopProtn %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 pAddBssParams->staContext.htCapable,
4392 pAddBssParams->staContext.greenFieldCapable,
4393 pAddBssParams->staContext.lsigTxopProtection);
4394 if (psessionEntry->vhtCapability &&
4395 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
4396 IS_BSS_VHT_CAPABLE(
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05304397 pBeaconStruct->vendor_vht_ie.VHTCaps))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 pAddBssParams->staContext.vhtCapable = 1;
4399 if (pBeaconStruct->VHTCaps.present)
4400 vht_caps = &pBeaconStruct->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05304401 else if (pBeaconStruct->vendor_vht_ie.VHTCaps.present)
4402 vht_caps = &pBeaconStruct->
4403 vendor_vht_ie.VHTCaps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404
4405 if ((vht_caps != NULL) && (vht_caps->suBeamFormerCap ||
Krunal Soni53993f72016-07-08 18:20:03 -07004406 vht_caps->muBeamformerCap) &&
4407 psessionEntry->vht_config.su_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 pAddBssParams->staContext.vhtTxBFCapable = 1;
4409
4410 if ((vht_caps != NULL) && vht_caps->muBeamformerCap &&
Krunal Soni53993f72016-07-08 18:20:03 -07004411 psessionEntry->vht_config.mu_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 pAddBssParams->staContext.vhtTxMUBformeeCapable
4413 = 1;
Krunal Soni53993f72016-07-08 18:20:03 -07004414
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 if ((vht_caps != NULL) && vht_caps->suBeamformeeCap &&
Krunal Soni53993f72016-07-08 18:20:03 -07004416 psessionEntry->vht_config.su_beam_former)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 pAddBssParams->staContext.enable_su_tx_bformer
4418 = 1;
Krunal Soni53993f72016-07-08 18:20:03 -07004419
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004420 pe_debug("StaContext: su_tx_bfer %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 pAddBssParams->staContext.enable_su_tx_bformer);
4422 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08004423 if (lim_is_session_he_capable(psessionEntry) &&
Naveen Rawatd8feac12017-09-08 15:08:39 -07004424 pBeaconStruct->he_cap.present)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08004425 lim_intersect_ap_he_caps(psessionEntry, pAddBssParams,
4426 pBeaconStruct, NULL);
4427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
4429 (chanWidthSupp)) {
4430 pAddBssParams->staContext.ch_width =
4431 (uint8_t) pBeaconStruct->HTInfo.
4432 recommendedTxWidthSet;
4433 if ((vht_oper != NULL) &&
4434 pAddBssParams->staContext.vhtCapable &&
4435 vht_oper->chanWidth)
4436 pAddBssParams->staContext.ch_width =
4437 vht_oper->chanWidth + 1;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004438 pe_debug("StaCtx: vhtCap %d ch_bw %d TxBF %d",
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07004439 pAddBssParams->staContext.vhtCapable,
4440 pAddBssParams->staContext.ch_width,
4441 pAddBssParams->staContext.vhtTxBFCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 } else {
4443 pAddBssParams->staContext.ch_width =
4444 CH_WIDTH_20MHZ;
4445 }
4446 pAddBssParams->staContext.mimoPS =
4447 (tSirMacHTMIMOPowerSaveState) pBeaconStruct->HTCaps.
4448 mimoPowerSave;
4449 pAddBssParams->staContext.maxAmsduSize =
4450 (uint8_t) pBeaconStruct->HTCaps.maximalAMSDUsize;
4451 pAddBssParams->staContext.maxAmpduDensity =
4452 pBeaconStruct->HTCaps.mpduDensity;
4453 pAddBssParams->staContext.fDsssCckMode40Mhz =
4454 (uint8_t) pBeaconStruct->HTCaps.dsssCckMode40MHz;
4455 /*
4456 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
4457 * if they are set then we will use what ever Beacon coming
4458 * from AP supports. If these values are set as 0 in ini file
4459 * then we will hardcode this values to 0.
4460 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07004461 if (true == psessionEntry->htConfig.ht_sgi20)
4462 pAddBssParams->staContext.fShortGI20Mhz =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 (uint8_t)pBeaconStruct->HTCaps.shortGI20MHz;
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07004464 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 pAddBssParams->staContext.fShortGI20Mhz =
4466 false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07004468 if (true == psessionEntry->htConfig.ht_sgi40)
4469 pAddBssParams->staContext.fShortGI40Mhz =
4470 (uint8_t) pBeaconStruct->HTCaps.shortGI40MHz;
4471 else
4472 pAddBssParams->staContext.fShortGI40Mhz = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473
4474 pAddBssParams->staContext.maxAmpduSize =
4475 pBeaconStruct->HTCaps.maxRxAMPDUFactor;
4476 if (pAddBssParams->staContext.vhtTxBFCapable
4477 && pMac->lim.disableLDPCWithTxbfAP) {
4478 pAddBssParams->staContext.htLdpcCapable = 0;
4479 pAddBssParams->staContext.vhtLdpcCapable = 0;
4480 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004481 if (psessionEntry->txLdpcIniFeatureEnabled & 0x1)
4482 pAddBssParams->staContext.htLdpcCapable =
4483 (uint8_t) pBeaconStruct->HTCaps.
4484 advCodingCap;
4485 else
4486 pAddBssParams->staContext.htLdpcCapable = 0;
4487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 if (pBeaconStruct->VHTCaps.present)
4489 vht_caps = &pBeaconStruct->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05304490 else if (pBeaconStruct->vendor_vht_ie.VHTCaps.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 vht_caps =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05304492 &pBeaconStruct->vendor_vht_ie.VHTCaps;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004493 pe_debug("VHT Caps are in vendor Specfic IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 }
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004495 if (vht_caps != NULL &&
4496 (psessionEntry->txLdpcIniFeatureEnabled & 0x2))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 pAddBssParams->staContext.vhtLdpcCapable =
4498 (uint8_t) vht_caps->ldpcCodingCap;
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08004499 else
4500 pAddBssParams->staContext.vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 }
4502
4503 if (pBeaconStruct->HTInfo.present)
4504 pAddBssParams->staContext.rifsMode =
4505 pBeaconStruct->HTInfo.rifsMode;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004506 pe_debug("StaContext ChannelWidth: %d mimoPS: %d maxAmsduSize: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 pAddBssParams->staContext.ch_width,
4508 pAddBssParams->staContext.mimoPS,
4509 pAddBssParams->staContext.maxAmsduSize);
4510
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004511 pe_debug("maxAmpduDensity %d Cck40Mhz %d SGI20Mhz %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 pAddBssParams->staContext.maxAmpduDensity,
4513 pAddBssParams->staContext.fDsssCckMode40Mhz,
4514 pAddBssParams->staContext.fShortGI20Mhz);
4515
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004516 pe_debug("SGI40M %d maxAmpdu %d htLdpc %d vhtLdpc %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 pAddBssParams->staContext.fShortGI40Mhz,
4518 pAddBssParams->staContext.maxAmpduSize,
4519 pAddBssParams->staContext.htLdpcCapable,
4520 pAddBssParams->staContext.vhtLdpcCapable);
4521 }
4522 /*
4523 * If WMM IE or 802.11E IE is not present
4524 * and AP is HT AP then enable WMM
4525 */
4526 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent ||
4527 pAddBssParams->staContext.htCapable)) ||
4528 (psessionEntry->limQosEnabled &&
4529 (pBeaconStruct->edcaPresent ||
4530 pAddBssParams->staContext.htCapable)))
4531 pAddBssParams->staContext.wmmEnabled = 1;
4532 else
4533 pAddBssParams->staContext.wmmEnabled = 0;
4534
4535 /* Update the rates */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 lim_populate_peer_rate_set(pMac,
4537 &pAddBssParams->staContext.
4538 supportedRates,
4539 pBeaconStruct->HTCaps.supportedMCSSet,
4540 false, psessionEntry,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07004541 &pBeaconStruct->VHTCaps,
Naveen Rawatd8feac12017-09-08 15:08:39 -07004542 &pBeaconStruct->he_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543
4544 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4545
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004547 pe_debug("maxTxPower: %d", pAddBssParams->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304549 pAddBssParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550 pAddBssParams->respReqd = true;
4551
4552 pAddBssParams->staContext.smesessionId = psessionEntry->smeSessionId;
4553 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4554 pAddBssParams->sessionId = psessionEntry->peSessionId;
4555
4556 pAddBssParams->halPersona = (uint8_t) psessionEntry->pePersona; /* update persona */
4557
4558 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
4559
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 pAddBssParams->extSetStaKeyParamValid = 0;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004561 pe_debug("extSetStaKeyParamValid: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 pAddBssParams->extSetStaKeyParamValid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563
4564#ifdef WLAN_FEATURE_11W
4565 if (psessionEntry->limRmfEnabled) {
4566 pAddBssParams->rmfEnabled = 1;
4567 pAddBssParams->staContext.rmfEnabled = 1;
4568 }
4569#endif
4570
4571 pAddBssParams->nss = psessionEntry->nss;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004572 pe_debug("nss value: %d", pAddBssParams->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573
4574 /* Set a new state for MLME */
4575 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4576
4577 MTRACE(mac_trace
4578 (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId,
4579 psessionEntry->limMlmState));
4580
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004581 pe_debug("staContext wmmEnabled: %d encryptType: %d "
4582 "p2pCapableSta: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 pAddBssParams->staContext.wmmEnabled,
4584 pAddBssParams->staContext.encryptType,
4585 pAddBssParams->staContext.p2pCapableSta);
4586
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004587 pe_debug("bSpectrumMgtEnabled: %d halPersona: %d setting "
4588 "LimMlm state to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 pAddBssParams->bSpectrumMgtEnabled, pAddBssParams->halPersona,
4590 psessionEntry->limMlmState);
4591
4592 /* we need to defer the message until we get the response back from HAL. */
4593 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4594
Naveen Rawat64e477e2016-05-20 10:34:56 -07004595 if (cds_is_5_mhz_enabled()) {
4596 pAddBssParams->ch_width = CH_WIDTH_5MHZ;
4597 pAddBssParams->staContext.ch_width = CH_WIDTH_5MHZ;
4598 } else if (cds_is_10_mhz_enabled()) {
4599 pAddBssParams->ch_width = CH_WIDTH_10MHZ;
4600 pAddBssParams->staContext.ch_width = CH_WIDTH_10MHZ;
4601 }
4602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 msgQ.type = WMA_ADD_BSS_REQ;
4604 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4605 msgQ.reserved = 0;
4606 msgQ.bodyptr = pAddBssParams;
4607 msgQ.bodyval = 0;
4608
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004609 pe_debug("SessionId:%d Sending WMA_ADD_BSS_REQ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 psessionEntry->peSessionId);
4611 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
4612
4613 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4614 if (eSIR_SUCCESS != retCode) {
4615 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304616 qdf_mem_free(pAddBssParams);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004617 pe_err("Posting ADD_BSS_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 retCode);
4619 goto returnFailure;
4620
4621 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304622 qdf_mem_free(pBeaconStruct);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 return retCode;
4624 }
4625
4626returnFailure:
4627 /* Clean-up will be done by the caller... */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304628 qdf_mem_free(pBeaconStruct);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 return retCode;
4630}
4631
4632/**
4633 * lim_prepare_and_send_del_sta_cnf() - prepares and send del sta cnf
4634 *
4635 * @pMac: mac global context
4636 * @pStaDs: sta dph node
4637 * @statusCode: status code
4638 * @psessionEntry: session context
4639 *
4640 * deletes DPH entry, changes the MLM mode for station, calls
4641 * lim_send_del_sta_cnf
4642 *
4643 * Return: void
4644 */
4645void
4646lim_prepare_and_send_del_sta_cnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
4647 tSirResultCodes statusCode,
4648 tpPESession psessionEntry)
4649{
4650 uint16_t staDsAssocId = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304651 struct qdf_mac_addr sta_dsaddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 tLimMlmStaContext mlmStaContext;
4653
4654 if (pStaDs == NULL) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004655 pe_err("pStaDs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 return;
4657 }
4658 staDsAssocId = pStaDs->assocId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304659 qdf_mem_copy((uint8_t *) sta_dsaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304660 pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661
4662 mlmStaContext = pStaDs->mlmStaContext;
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07004663 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07004665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr, pStaDs->assocId,
4667 psessionEntry);
4668
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07004669 if (LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
4671 MTRACE(mac_trace(pMac, TRACE_CODE_MLM_STATE,
4672 psessionEntry->peSessionId,
4673 psessionEntry->limMlmState));
4674 }
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08004675 lim_send_del_sta_cnf(pMac, sta_dsaddr, staDsAssocId, mlmStaContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 statusCode, psessionEntry);
4677}
4678
4679/** -------------------------------------------------------------
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 \fn lim_init_pre_auth_timer_table
4681 \brief Initialize the Pre Auth Tanle and creates the timer for
4682 each node for the timeout value got from cfg.
4683 \param tpAniSirGlobal pMac
4684 \param tpLimPreAuthTable pPreAuthTimerTable
4685 \return none
4686 -------------------------------------------------------------*/
4687void lim_init_pre_auth_timer_table(tpAniSirGlobal pMac,
4688 tpLimPreAuthTable pPreAuthTimerTable)
4689{
4690 uint32_t cfgValue;
4691 uint32_t authNodeIdx;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004692
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004693 tLimPreAuthNode **pAuthNode = pPreAuthTimerTable->pTable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694
4695 /* Get AUTH_RSP Timers value */
4696
4697 if (wlan_cfg_get_int(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4698 &cfgValue) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004699 pe_err("could not retrieve AUTH_RSP timeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 return;
4701 }
4702
4703 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4704 for (authNodeIdx = 0; authNodeIdx < pPreAuthTimerTable->numEntry;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004705 authNodeIdx++) {
4706 if (tx_timer_create(pMac, &(pAuthNode[authNodeIdx]->timer),
Naveen Rawat22b1a932015-08-26 12:13:18 -07004707 "AUTH RESPONSE TIMEOUT",
4708 lim_auth_response_timer_handler, authNodeIdx,
4709 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004710 pe_err("Cannot create Auth Rsp timer of Index: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 authNodeIdx);
4712 return;
4713 }
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004714 pAuthNode[authNodeIdx]->authNodeIdx = (uint8_t) authNodeIdx;
4715 pAuthNode[authNodeIdx]->fFree = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717}
4718
4719/** -------------------------------------------------------------
4720 \fn lim_acquire_free_pre_auth_node
4721 \brief Retrives a free Pre Auth node from Pre Auth Table.
4722 \param tpAniSirGlobal pMac
4723 \param tpLimPreAuthTable pPreAuthTimerTable
4724 \return none
4725 -------------------------------------------------------------*/
4726tLimPreAuthNode *lim_acquire_free_pre_auth_node(tpAniSirGlobal pMac,
4727 tpLimPreAuthTable pPreAuthTimerTable)
4728{
4729 uint32_t i;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004730 tLimPreAuthNode **pTempNode = pPreAuthTimerTable->pTable;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004731
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004732 for (i = 0; i < pPreAuthTimerTable->numEntry; i++) {
4733 if (pTempNode[i]->fFree == 1) {
4734 pTempNode[i]->fFree = 0;
4735 return pTempNode[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004736 }
4737 }
4738
4739 return NULL;
4740}
4741
4742/** -------------------------------------------------------------
4743 \fn lim_get_pre_auth_node_from_index
4744 \brief Depending on the Index this retrives the pre auth node.
4745 \param tpAniSirGlobal pMac
4746 \param tpLimPreAuthTable pAuthTable
4747 \param uint32_t authNodeIdx
4748 \return none
4749 -------------------------------------------------------------*/
4750tLimPreAuthNode *lim_get_pre_auth_node_from_index(tpAniSirGlobal pMac,
4751 tpLimPreAuthTable pAuthTable,
4752 uint32_t authNodeIdx)
4753{
4754 if ((authNodeIdx >= pAuthTable->numEntry)
4755 || (pAuthTable->pTable == NULL)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004756 pe_err("Invalid Auth Timer Index: %d NumEntry: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757 authNodeIdx, pAuthTable->numEntry);
4758 return NULL;
4759 }
4760
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004761 return pAuthTable->pTable[authNodeIdx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762}
4763
4764/* Util API to check if the channels supported by STA is within range */
4765tSirRetStatus lim_is_dot11h_supported_channels_valid(tpAniSirGlobal pMac,
4766 tSirAssocReq *assoc)
4767{
4768 /*
4769 * Allow all the stations to join with us.
4770 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4771 * as an input into an algorithm used to select a new channel for the BSS.
4772 * The specification of the algorithm is beyond the scope of this amendment.
4773 */
4774
4775 return eSIR_SUCCESS;
4776}
4777
4778/* Util API to check if the txpower supported by STA is within range */
4779tSirRetStatus lim_is_dot11h_power_capabilities_in_range(tpAniSirGlobal pMac,
4780 tSirAssocReq *assoc,
4781 tpPESession psessionEntry)
4782{
Amar Singhala297bfa2015-10-15 15:07:29 -07004783 int8_t localMaxTxPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004784 uint32_t localPwrConstraint;
4785
4786 localMaxTxPower =
4787 cfg_get_regulatory_max_transmit_power(pMac,
4788 psessionEntry->currentOperChannel);
4789
4790 if (wlan_cfg_get_int
4791 (pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT,
4792 &localPwrConstraint) != eSIR_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004793 pe_err("Unable to get Local Power Constraint from cfg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 return eSIR_FAILURE;
4795 }
Amar Singhala297bfa2015-10-15 15:07:29 -07004796 localMaxTxPower -= (int8_t) localPwrConstraint;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797
4798 /**
4799 * The min Tx Power of the associating station should not be greater than (regulatory
4800 * max tx power - local power constraint configured on AP).
4801 */
4802 if (assoc->powerCapability.minTxPower > localMaxTxPower) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004803 pe_warn("minTxPower (STA): %d, localMaxTxPower (AP): %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804 assoc->powerCapability.minTxPower, localMaxTxPower);
4805 return eSIR_FAILURE;
4806 }
4807
4808 return eSIR_SUCCESS;
4809}
4810
4811/** -------------------------------------------------------------
4812 \fn lim_fill_rx_highest_supported_rate
4813 \brief Fills in the Rx Highest Supported Data Rate field from
4814 \ the 'supported MCS set' field in HT capability element.
4815 \param tpAniSirGlobal pMac
4816 \param tpSirSupportedRates pRates
4817 \param uint8_t* pSupportedMCSSet
4818 \return none
4819 -------------------------------------------------------------*/
4820void lim_fill_rx_highest_supported_rate(tpAniSirGlobal pMac,
4821 uint16_t *rxHighestRate,
4822 uint8_t *pSupportedMCSSet)
4823{
4824 tSirMacRxHighestSupportRate *pRxHighestRate;
4825 uint8_t *pBuf;
4826 uint16_t rate = 0;
4827
4828 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4829 rate = lim_get_u16(pBuf);
4830
4831 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4832 *rxHighestRate = pRxHighestRate->rate;
4833
4834 return;
4835}
4836
4837#ifdef WLAN_FEATURE_11W
4838/** -------------------------------------------------------------
4839 \fn lim_send_sme_unprotected_mgmt_frame_ind
4840 \brief Forwards the unprotected management frame to SME.
4841 \param tpAniSirGlobal pMac
4842 \param frameType - 802.11 frame type
4843 \param frame - frame buffer
4844 \param sessionId - id for the current session
4845 \param psessionEntry - PE session context
4846 \return none
4847 -------------------------------------------------------------*/
4848void lim_send_sme_unprotected_mgmt_frame_ind(tpAniSirGlobal pMac, uint8_t frameType,
4849 uint8_t *frame, uint32_t frameLen,
4850 uint16_t sessionId,
4851 tpPESession psessionEntry)
4852{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004853 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004854 tSirSmeUnprotMgmtFrameInd *pSirSmeMgmtFrame = NULL;
4855 uint16_t length;
4856
4857 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4858
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304859 pSirSmeMgmtFrame = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 if (NULL == pSirSmeMgmtFrame) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004861 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862 return;
4863 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864
4865 pSirSmeMgmtFrame->sessionId = sessionId;
4866 pSirSmeMgmtFrame->frameType = frameType;
4867
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304868 qdf_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 pSirSmeMgmtFrame->frameLen = frameLen;
4870
4871 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4872 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4873 mmhMsg.bodyval = 0;
4874
4875 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
4876 return;
4877}
4878#endif
4879
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004880#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881/** -------------------------------------------------------------
4882 \fn lim_send_sme_tsm_ie_ind
4883 \brief Forwards the TSM IE information to SME.
4884 \param tpAniSirGlobal pMac
4885 \param psessionEntry - PE session context
4886 \param tid - traffic id
4887 \param state - tsm state (enabled/disabled)
4888 \param measurementInterval - measurement interval
4889 \return none
4890 -------------------------------------------------------------*/
4891void lim_send_sme_tsm_ie_ind(tpAniSirGlobal pMac, tpPESession psessionEntry,
4892 uint8_t tid, uint8_t state, uint16_t measInterval)
4893{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004894 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 tpSirSmeTsmIEInd pSirSmeTsmIeInd = NULL;
4896
4897 if (!pMac || !psessionEntry)
4898 return;
4899
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304900 pSirSmeTsmIeInd = qdf_mem_malloc(sizeof(tSirSmeTsmIEInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901 if (NULL == pSirSmeTsmIeInd) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004902 pe_err("AllocateMemory failed for tSirSmeTsmIEInd");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 return;
4904 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905
4906 pSirSmeTsmIeInd->sessionId = psessionEntry->smeSessionId;
4907 pSirSmeTsmIeInd->tsmIe.tsid = tid;
4908 pSirSmeTsmIeInd->tsmIe.state = state;
4909 pSirSmeTsmIeInd->tsmIe.msmt_interval = measInterval;
4910
4911 mmhMsg.type = eWNI_SME_TSM_IE_IND;
4912 mmhMsg.bodyptr = pSirSmeTsmIeInd;
4913 mmhMsg.bodyval = 0;
4914
4915 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
4916 return;
4917}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004918#endif /* FEATURE_WLAN_ESE */