blob: 8ee730e9b1932686ffd9898145aa00069590febd [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Amruta Kulkarni4edc97d2019-12-18 16:13:07 -08002 * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_assoc_utils.cc contains the utility functions
21 * LIM uses while processing (Re) Association messages.
22 * Author: Chandra Modumudi
23 * Date: 02/13/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 * 05/26/10 js WPA handling in (Re)Assoc frames
28 *
29 */
30
31#include "cds_api.h"
32#include "ani_global.h"
33#include "wni_api.h"
34#include "sir_common.h"
35
36#include "wni_cfg.h"
Arif Hussain43e09712018-09-18 19:31:57 -070037#include "cfg_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038
39#include "sch_api.h"
40#include "utils_api.h"
41#include "lim_utils.h"
42#include "lim_assoc_utils.h"
43#include "lim_security_utils.h"
44#include "lim_ser_des_utils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "lim_admit_control.h"
46#include "lim_send_messages.h"
47#include "lim_ibss_peer_mgmt.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "lim_session.h"
bings11172832019-05-23 16:41:25 +080050#include "lim_process_fils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051
Anurag Chouhan6d760662016-02-20 16:05:43 +053052#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include "wma_types.h"
54#include "lim_types.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070055#include "wlan_utility.h"
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +053056#include "wlan_mlme_api.h"
Jianmin Zhu9772c4a2019-08-14 16:38:05 +080057#include "wma.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058
Yingying Tanga1863be2017-03-22 18:10:43 +080059#ifdef FEATURE_WLAN_TDLS
60#define IS_TDLS_PEER(type) ((type) == STA_ENTRY_TDLS_PEER)
61#else
62#define IS_TDLS_PEER(type) 0
63#endif
64
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065/**
Srinivas Girigowdacba74732016-01-14 17:35:25 -080066 * lim_cmp_ssid() - utility function to compare SSIDs
67 * @rx_ssid: Received SSID
68 * @session_entry: Session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 * This function is called in various places within LIM code
Srinivas Girigowdacba74732016-01-14 17:35:25 -080071 * to determine whether received SSID is same as SSID in use.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072 *
Ankit Guptad66a8812016-09-15 11:00:16 -070073 * Return: zero if SSID matched, non-zero otherwise.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074 */
Jeff Johnsonec50d0d2018-11-18 22:19:01 -080075uint32_t lim_cmp_ssid(tSirMacSSid *rx_ssid, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053077 return qdf_mem_cmp(rx_ssid, &session_entry->ssId,
Srinivas Girigowdacba74732016-01-14 17:35:25 -080078 session_entry->ssId.length);
79}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080
81/**
82 * lim_compare_capabilities()
83 *
84 ***FUNCTION:
85 * This function is called during Association/Reassociation
86 * frame handling to determine whether received capabilities
87 * match with local capabilities or not.
88 *
89 ***LOGIC:
90 *
91 ***ASSUMPTIONS:
92 * NA
93 *
94 ***NOTE:
95 * NA
96 *
Jeff Johnsonab322b92018-11-21 23:10:49 -080097 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098 * @param pAssocReq - Pointer to received Assoc Req frame
99 * @param pLocalCapabs - Pointer to local capabilities
100 *
101 * @return status - true for Capabilitity match else false.
102 */
103
104uint8_t
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800105lim_compare_capabilities(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106 tSirAssocReq *pAssocReq,
107 tSirMacCapabilityInfo *pLocalCapabs,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800108 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109{
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800110 if (LIM_IS_AP_ROLE(pe_session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 (pAssocReq->capabilityInfo.ibss)) {
112 /* Requesting STA asserting IBSS capability. */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700113 pe_debug("Requesting STA asserting IBSS capability");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 return false;
115 }
116 /* Compare CF capabilities */
117 if (pAssocReq->capabilityInfo.cfPollable ||
118 pAssocReq->capabilityInfo.cfPollReq) {
119 /* AP does not support PCF functionality */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700120 pe_debug(" AP does not support PCF functionality");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121 return false;
122 }
123 /* Compare short preamble capability */
124 if (pAssocReq->capabilityInfo.shortPreamble &&
125 (pAssocReq->capabilityInfo.shortPreamble !=
126 pLocalCapabs->shortPreamble)) {
127 /* Allowing a STA requesting short preamble while */
128 /* AP does not support it */
129 }
130
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700131 pe_debug("QoS in AssocReq: %d, local capabs qos: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800132 pAssocReq->capabilityInfo.qos, pLocalCapabs->qos);
133
134 /* Compare QoS capability */
135 if (pAssocReq->capabilityInfo.qos &&
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700136 (pAssocReq->capabilityInfo.qos != pLocalCapabs->qos))
137 pe_debug("Received unmatched QOS but cfg to suppress - continuing");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138
139 /*
140 * If AP supports shortSlot and if apple user has
141 * enforced association only from shortSlot station,
142 * then AP must reject any station that does not support
143 * shortSlot
144 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800145 if (LIM_IS_AP_ROLE(pe_session) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 (pLocalCapabs->shortSlotTime == 1)) {
Jeff Johnsonab322b92018-11-21 23:10:49 -0800147 if (mac->mlme_cfg->feature_flags.accept_short_slot_assoc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 if (pAssocReq->capabilityInfo.shortSlotTime !=
149 pLocalCapabs->shortSlotTime) {
Jeff Johnson33142e62018-05-06 17:58:36 -0700150 pe_err("AP rejects association as station doesn't support shortslot time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 return false;
152 }
153 return false;
154 }
155 }
156
157 return true;
158} /****** end lim_compare_capabilities() ******/
159
160/**
161 * lim_check_rx_basic_rates()
162 *
163 ***FUNCTION:
164 * This function is called during Association/Reassociation
165 * frame handling to determine whether received rates in
166 * Assoc/Reassoc request frames include all BSS basic rates
167 * or not.
168 *
169 ***LOGIC:
170 *
171 ***ASSUMPTIONS:
172 * NA
173 *
174 ***NOTE:
175 * NA
176 *
177 * @param rxRateSet - pointer to SSID structure
178 *
179 * @return status - true if ALL BSS basic rates are present in the
180 * received rateset else false.
181 */
182
183uint8_t
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800184lim_check_rx_basic_rates(struct mac_context *mac, tSirMacRateSet rxRateSet,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800185 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186{
187 tSirMacRateSet *pRateSet, basicRate;
188 uint8_t i, j, k, match;
189
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530190 pRateSet = qdf_mem_malloc(sizeof(tSirMacRateSet));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700191 if (!pRateSet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193
194 /* Copy operational rate set from session Entry */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800195 qdf_mem_copy(pRateSet->rate, (pe_session->rateSet.rate),
196 pe_session->rateSet.numRates);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800198 pRateSet->numRates = pe_session->rateSet.numRates;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199
200 /* Extract BSS basic rateset from operational rateset */
201 for (i = 0, j = 0;
Srinivas Girigowda61771262019-04-01 11:55:19 -0700202 ((i < pRateSet->numRates) && (i < WLAN_SUPPORTED_RATES_IE_MAX_LEN)); i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 if ((pRateSet->rate[i] & 0x80) == 0x80) {
204 /* msb is set, so this is a basic rate */
205 basicRate.rate[j++] = pRateSet->rate[i];
206 }
207 }
208
209 /*
210 * For each BSS basic rate, find if it is present in the
211 * received rateset.
212 */
213 for (k = 0; k < j; k++) {
214 match = 0;
215 for (i = 0;
216 ((i < rxRateSet.numRates)
Srinivas Girigowda61771262019-04-01 11:55:19 -0700217 && (i < WLAN_SUPPORTED_RATES_IE_MAX_LEN)); i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 if ((rxRateSet.rate[i] | 0x80) == basicRate.rate[k])
219 match = 1;
220 }
221
222 if (!match) {
223 /* Free up memory allocated for rateset */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530224 qdf_mem_free((uint8_t *) pRateSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225
226 return false;
227 }
228 }
229
230 /* Free up memory allocated for rateset */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530231 qdf_mem_free((uint8_t *) pRateSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232
233 return true;
234} /****** end lim_check_rx_basic_rates() ******/
235
236/**
237 * lim_check_mcs_set()
238 *
239 ***FUNCTION:
240 * This function is called during Association/Reassociation
241 * frame handling to determine whether received MCS rates in
242 * Assoc/Reassoc request frames includes all Basic MCS Rate Set or not.
243 *
244 ***LOGIC:
245 *
246 ***ASSUMPTIONS:
247 * NA
248 *
249 ***NOTE:
250 * NA
251 *
252 * @param supportedMCSSet - pointer to Supported MCS Rate Set
253 *
254 * @return status - true if ALL MCS Basic Rate Set rates are present in the
255 * received rateset else false.
256 */
257
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800258uint8_t lim_check_mcs_set(struct mac_context *mac, uint8_t *supportedMCSSet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259{
260 uint8_t basicMCSSet[SIZE_OF_BASIC_MCS_SET] = { 0 };
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +0530261 qdf_size_t cfg_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 uint8_t i;
263 uint8_t validBytes;
264 uint8_t lastByteMCSMask = 0x1f;
265
Jeff Johnsonab322b92018-11-21 23:10:49 -0800266 cfg_len = mac->mlme_cfg->rates.basic_mcs_set.len;
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +0530267 if (wlan_mlme_get_cfg_str((uint8_t *)basicMCSSet,
Jeff Johnsonab322b92018-11-21 23:10:49 -0800268 &mac->mlme_cfg->rates.basic_mcs_set,
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +0530269 &cfg_len) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 /* / Could not get Basic MCS rateset from CFG. Log error. */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700271 pe_err("could not retrieve Basic MCS rateset");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 return false;
273 }
274
275 validBytes = VALID_MCS_SIZE / 8;
276
277 /* check if all the Basic MCS Bits are set in supported MCS bitmap */
278 for (i = 0; i < validBytes; i++) {
279 if ((basicMCSSet[i] & supportedMCSSet[i]) != basicMCSSet[i]) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700280 pe_warn("One of Basic MCS Set Rates is not supported by the Station");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 return false;
282 }
283 }
284
285 /* check the last 5 bits of the valid MCS bitmap */
286 if (((basicMCSSet[i] & lastByteMCSMask) &
287 (supportedMCSSet[i] & lastByteMCSMask)) !=
288 (basicMCSSet[i] & lastByteMCSMask)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700289 pe_warn("One of Basic MCS Set Rates is not supported by the Station");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290 return false;
291 }
292
293 return true;
294}
295
296#define SECURITY_SUITE_TYPE_MASK 0xFF
297#define SECURITY_SUITE_TYPE_WEP40 0x1
298#define SECURITY_SUITE_TYPE_TKIP 0x2
299#define SECURITY_SUITE_TYPE_CCMP 0x4
300#define SECURITY_SUITE_TYPE_WEP104 0x4
Mukul Sharma05504ac2017-06-08 12:35:53 +0530301#define SECURITY_SUITE_TYPE_GCMP 0x8
302#define SECURITY_SUITE_TYPE_GCMP_256 0x9
303
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304/**
305 * lim_cleanup_rx_path()
306 *
307 ***FUNCTION:
308 * This function is called to cleanup STA state at SP & RFP.
309 *
310 ***LOGIC:
311 * To circumvent RFP's handling of dummy packet when it does not
312 * have an incomplete packet for the STA to be deleted, a packet
313 * with 'more framgents' bit set will be queued to RFP's WQ before
314 * queuing 'dummy packet'.
315 * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
316 * (Disassociation frame) and routing flags in BD set to eCPU's
317 * Low Priority WQ.
318 * RFP cleans up its local context for the STA id mentioned in the
319 * BD and then pushes BD to eCPU's low priority WQ.
320 *
321 ***ASSUMPTIONS:
322 * NA
323 *
324 ***NOTE:
325 * NA
326 *
Jeff Johnsonab322b92018-11-21 23:10:49 -0800327 * @param mac Pointer to Global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800328 * @param sta Pointer to the per STA data structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 * initialized by LIM and maintained at DPH
330 *
331 * @return None
332 */
333
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700334QDF_STATUS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800335lim_cleanup_rx_path(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800336 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700338 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700340 pe_debug("Cleanup Rx Path for AID: %d"
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800341 "pe_session->limSmeState: %d, mlmState: %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800342 sta->assocId, pe_session->limSmeState,
343 sta->mlmStaContext.mlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800345 pe_session->isCiscoVendorAP = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346
Jeff Johnsonab322b92018-11-21 23:10:49 -0800347 if (mac->lim.gLimAddtsSent) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 MTRACE(mac_trace
Jeff Johnsonab322b92018-11-21 23:10:49 -0800349 (mac, TRACE_CODE_TIMER_DEACTIVATE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800350 pe_session->peSessionId, eLIM_ADDTS_RSP_TIMER));
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +0530351 tx_timer_deactivate(&mac->lim.lim_timers.gLimAddtsRspTimer);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700352 pe_debug("Reset gLimAddtsSent flag and send addts timeout to SME");
Jeff Johnsonab322b92018-11-21 23:10:49 -0800353 lim_process_sme_addts_rsp_timeout(mac,
354 mac->lim.gLimAddtsRspTimerCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 }
356
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800357 if (sta->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE) {
Jeff Johnsonab322b92018-11-21 23:10:49 -0800358 lim_deactivate_and_change_per_sta_id_timer(mac, eLIM_CNF_WAIT_TIMER,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800359 sta->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800361 if (!sta->mlmStaContext.updateContext) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 /**
363 * There is no context at Polaris to delete.
364 * Release our assigned AID back to the free pool
365 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800366 if (LIM_IS_AP_ROLE(pe_session)) {
Sandeep Puligilla32773292020-12-08 21:50:04 -0800367 lim_del_sta(mac, sta, true, pe_session);
368 return retCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 }
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800370 lim_delete_dph_hash_entry(mac, sta->staAddr,
371 sta->assocId, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372
373 return retCode;
374 }
375 }
376 /* delete all tspecs associated with this sta. */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800377 lim_admit_control_delete_sta(mac, sta->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378
379 /**
380 * Make STA hash entry invalid at eCPU so that DPH
381 * does not process any more data packets and
382 * releases those BDs
383 */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800384 sta->valid = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800385 lim_send_sme_tsm_ie_ind(mac, pe_session, 0, 0, 0);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800386 /* Any roaming related changes should be above this line */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800387 if (lim_is_roam_synch_in_progress(pe_session))
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700388 return QDF_STATUS_SUCCESS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800389 sta->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800391 if (LIM_IS_STA_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800393 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800395 pe_session->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 /* Deactivating probe after heart beat timer */
Jeff Johnsonab322b92018-11-21 23:10:49 -0800397 lim_deactivate_and_change_timer(mac, eLIM_PROBE_AFTER_HB_TIMER);
398 lim_deactivate_and_change_timer(mac, eLIM_JOIN_FAIL_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 }
400#ifdef WLAN_DEBUG
401 /* increment a debug count */
Jeff Johnsonab322b92018-11-21 23:10:49 -0800402 mac->lim.gLimNumRxCleanup++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403#endif
Abhishek Singh96bda8e2015-12-03 16:45:35 +0530404 /* Do DEL BSS or DEL STA only if ADD BSS was success */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800405 if (!pe_session->add_bss_failed) {
406 if (pe_session->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
Abhishek Singh96bda8e2015-12-03 16:45:35 +0530407 retCode =
Abhishek Singhc70afa32019-09-19 15:17:21 +0530408 lim_del_bss(mac, sta, pe_session->vdev_id,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800409 pe_session);
Abhishek Singh96bda8e2015-12-03 16:45:35 +0530410 } else
Jeff Johnsonab322b92018-11-21 23:10:49 -0800411 retCode = lim_del_sta(mac,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800412 sta, true, pe_session);
Abhishek Singh96bda8e2015-12-03 16:45:35 +0530413 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414
415 return retCode;
416
417} /*** end lim_cleanup_rx_path() ***/
418
419/**
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800420 * lim_send_del_sta_cnf() - Send Del sta confirmation
Jeff Johnsonab322b92018-11-21 23:10:49 -0800421 * @mac: Pointer to Global MAC structure
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800422 * @sta_dsaddr: sta ds address
423 * @staDsAssocId: sta ds association id
424 * @mlmStaContext: MLM station context
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530425 * @status_code: Status code
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800426 * @pe_session: Session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 *
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800428 * This function is called to send appropriate CNF message to SME.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 *
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -0800430 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800433lim_send_del_sta_cnf(struct mac_context *mac, struct qdf_mac_addr sta_dsaddr,
Pragaspathi Thilagarajb3d52532019-06-22 22:37:55 +0530434 uint16_t staDsAssocId,
435 struct lim_sta_context mlmStaContext,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530436 tSirResultCodes status_code, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 tLimMlmDisassocCnf mlmDisassocCnf;
439 tLimMlmDeauthCnf mlmDeauthCnf;
440 tLimMlmPurgeStaInd mlmPurgeStaInd;
441
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700442 pe_debug("Sessionid: %d staDsAssocId: %d Trigger: %d status_code: %d sta_dsaddr: "QDF_MAC_ADDR_FMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800443 pe_session->peSessionId, staDsAssocId,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530444 mlmStaContext.cleanupTrigger, status_code,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700445 QDF_MAC_ADDR_REF(sta_dsaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800447 if (LIM_IS_STA_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 /* Set BSSID at CFG to null */
449 tSirMacAddr nullAddr = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
450
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800451 sir_copy_mac_addr(nullAddr, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452
453 /* Free up buffer allocated for JoinReq held by */
454 /* MLM state machine */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800455 if (pe_session->pLimMlmJoinReq) {
456 qdf_mem_free(pe_session->pLimMlmJoinReq);
457 pe_session->pLimMlmJoinReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 }
459
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800460 pe_session->limAID = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 }
462
463 if ((mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +0530464 eLIM_HOST_DISASSOC) ||
465 (mlmStaContext.cleanupTrigger ==
466 eLIM_LINK_MONITORING_DISASSOC) ||
467 (mlmStaContext.cleanupTrigger ==
468 eLIM_PROMISCUOUS_MODE_DISASSOC)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530469 qdf_mem_copy((uint8_t *) &mlmDisassocCnf.peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530470 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530471 mlmDisassocCnf.resultCode = status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 mlmDisassocCnf.disassocTrigger = mlmStaContext.cleanupTrigger;
473 /* Update PE session Id */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800474 mlmDisassocCnf.sessionId = pe_session->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475
Jeff Johnsonab322b92018-11-21 23:10:49 -0800476 lim_post_sme_message(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 LIM_MLM_DISASSOC_CNF,
478 (uint32_t *) &mlmDisassocCnf);
479 } else if ((mlmStaContext.cleanupTrigger ==
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +0530480 eLIM_HOST_DEAUTH) ||
481 (mlmStaContext.cleanupTrigger ==
482 eLIM_LINK_MONITORING_DEAUTH)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530483 qdf_copy_macaddr(&mlmDeauthCnf.peer_macaddr, &sta_dsaddr);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530484 mlmDeauthCnf.resultCode = status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 mlmDeauthCnf.deauthTrigger = mlmStaContext.cleanupTrigger;
486 /* PE session Id */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800487 mlmDeauthCnf.sessionId = pe_session->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488
Jeff Johnsonab322b92018-11-21 23:10:49 -0800489 lim_post_sme_message(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490 LIM_MLM_DEAUTH_CNF,
491 (uint32_t *) &mlmDeauthCnf);
492 } else if ((mlmStaContext.cleanupTrigger ==
493 eLIM_PEER_ENTITY_DISASSOC) ||
494 (mlmStaContext.cleanupTrigger == eLIM_PEER_ENTITY_DEAUTH)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530495 qdf_mem_copy((uint8_t *) &mlmPurgeStaInd.peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530496 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497 mlmPurgeStaInd.reasonCode =
498 (uint8_t) mlmStaContext.disassocReason;
499 mlmPurgeStaInd.aid = staDsAssocId;
500 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800501 mlmPurgeStaInd.sessionId = pe_session->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502
Jeff Johnsonab322b92018-11-21 23:10:49 -0800503 lim_post_sme_message(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504 LIM_MLM_PURGE_STA_IND,
505 (uint32_t *) &mlmPurgeStaInd);
506 } else if (mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE) {
507 /* PE setup the peer entry in HW upfront, right after join is completed. */
508 /* If there is a failure during rest of the assoc sequence, this context needs to be cleaned up. */
509 uint8_t smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800511 smesessionId = pe_session->smeSessionId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800512 pe_session->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800514 (mac, TRACE_CODE_SME_STATE, pe_session->peSessionId,
515 pe_session->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516
517 /* if it is a reassoc failure to join new AP */
518 if ((mlmStaContext.resultCode ==
519 eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE)
520 || (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE)
521 || (mlmStaContext.resultCode ==
522 eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700523 pe_debug("Lim Posting eWNI_SME_REASSOC_RSP to SME"
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530524 "resultCode: %d, status_code: %d,"
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700525 "sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800526 mlmStaContext.resultCode,
527 mlmStaContext.protStatusCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800528 pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529
Jeff Johnsonab322b92018-11-21 23:10:49 -0800530 lim_send_sme_join_reassoc_rsp(mac, eWNI_SME_REASSOC_RSP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 mlmStaContext.resultCode,
532 mlmStaContext.protStatusCode,
Jeff Johnson27b98962019-02-20 20:53:08 -0800533 pe_session, smesessionId);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530534 if (mlmStaContext.resultCode != eSIR_SME_SUCCESS) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800535 pe_delete_session(mac, pe_session);
536 pe_session = NULL;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530537 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800538 } else {
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +0530539 qdf_mem_free(pe_session->lim_join_req);
540 pe_session->lim_join_req = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700542 pe_debug("Lim Posting eWNI_SME_JOIN_RSP to SME."
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530543 "resultCode: %d,status_code: %d,"
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700544 "sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 mlmStaContext.resultCode,
546 mlmStaContext.protStatusCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800547 pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800548
Jeff Johnsonab322b92018-11-21 23:10:49 -0800549 lim_send_sme_join_reassoc_rsp(mac, eWNI_SME_JOIN_RSP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 mlmStaContext.resultCode,
551 mlmStaContext.protStatusCode,
Jeff Johnson27b98962019-02-20 20:53:08 -0800552 pe_session, smesessionId);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530553
554 if (mlmStaContext.resultCode != eSIR_SME_SUCCESS) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800555 pe_delete_session(mac, pe_session);
556 pe_session = NULL;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530557 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 }
559
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700560 } else if (mlmStaContext.cleanupTrigger == eLIM_DUPLICATE_ENTRY) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700561
562 qdf_mem_copy((uint8_t *) &mlmDisassocCnf.peerMacAddr,
563 (uint8_t *) sta_dsaddr.bytes, QDF_MAC_ADDR_SIZE);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530564 mlmDisassocCnf.resultCode = status_code;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700565 mlmDisassocCnf.disassocTrigger = eLIM_DUPLICATE_ENTRY;
566 /* Update PE session Id */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800567 mlmDisassocCnf.sessionId = pe_session->peSessionId;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700568
Jeff Johnsonab322b92018-11-21 23:10:49 -0800569 lim_post_sme_message(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700570 LIM_MLM_DISASSOC_CNF,
571 (uint32_t *) &mlmDisassocCnf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572 }
573
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700574 if (pe_session && !LIM_IS_AP_ROLE(pe_session)) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800575 pe_delete_session(mac, pe_session);
576 pe_session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 }
578}
579
580/**
581 * lim_reject_association() - function to reject Re/Association Request
582 *
583 * @mac_ctx: pointer to global mac structure
584 * @peer_addr: mac address of the peer
585 * @sub_type: Indicates whether it is Association Request (=0) or
586 * Reassociation Request (=1) frame
587 * @add_pre_auth_context:Indicates whether pre-auth context
588 * to be added for this STA
589 * @auth_type: Indicates auth type to be added
590 * @sta_id: Indicates staId of the STA being rejected
591 * association
592 * @delete_sta: Indicates whether to delete STA context
593 * at Polaris
594 * @result_code: Indicates what reasonCode to be sent in
595 * Re/Assoc response to STA
596 * @session_entry: pointer to PE session
597 *
598 * This function is called whenever Re/Association Request need
599 * to be rejected due to failure in assigning an AID or failure
600 * in adding STA context at Polaris or reject by applications.
601 * Resources allocated if any are freedup and (Re) Association
602 * Response frame is sent to requesting STA. Pre-Auth context
603 * will be added for this STA if it does not exist already
604 *
605 * Return: none
606 */
607
608void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800609lim_reject_association(struct mac_context *mac_ctx, tSirMacAddr peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 uint8_t sub_type, uint8_t add_pre_auth_context,
611 tAniAuthType auth_type, uint16_t sta_id,
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +0530612 uint8_t delete_sta, enum mac_status_code result_code,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -0800613 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614{
615 tpDphHashNode sta_ds;
616
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700617 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: " QDF_MAC_ADDR_FMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 session_entry->peSessionId, auth_type, sub_type,
619 add_pre_auth_context, sta_id, delete_sta, result_code,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700620 QDF_MAC_ADDR_REF(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621
622 if (add_pre_auth_context) {
623 /* Create entry for this STA in pre-auth list */
624 struct tLimPreAuthNode *auth_node;
625
626 auth_node = lim_acquire_free_pre_auth_node(mac_ctx,
627 &mac_ctx->lim.gLimPreAuthTimerTable);
628
629 if (auth_node) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530630 qdf_mem_copy((uint8_t *) auth_node->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 peer_addr, sizeof(tSirMacAddr));
632 auth_node->fTimerStarted = 0;
633 auth_node->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
634 auth_node->authType = (tAniAuthType) auth_type;
Anurag Chouhan210db072016-02-22 18:42:15 +0530635 auth_node->timestamp = qdf_mc_timer_get_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 lim_add_pre_auth_node(mac_ctx, auth_node);
637 }
638 }
639
640 if (delete_sta == false) {
bings85512332019-09-04 17:46:37 +0800641 lim_send_assoc_rsp_mgmt_frame(
642 mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
bings85512332019-09-04 17:46:37 +0800644 1, peer_addr, sub_type, 0, session_entry,
645 false);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700646 pe_warn("received Re/Assoc req when max associated STAs reached from");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 lim_print_mac_addr(mac_ctx, peer_addr, LOGW);
648 lim_send_sme_max_assoc_exceeded_ntf(mac_ctx, peer_addr,
649 session_entry->smeSessionId);
650 return;
651 }
652
653 sta_ds = dph_get_hash_entry(mac_ctx, sta_id,
654 &session_entry->dph.dphHashTable);
655
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700656 if (!sta_ds) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700657 pe_err("No STA context, yet rejecting Association");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 return;
659 }
660
661 /*
662 * Polaris has state for this STA.
663 * Trigger cleanup.
664 */
665 sta_ds->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
666
667 /* Receive path cleanup */
668 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
669
670 /*
671 * Send Re/Association Response with
672 * status code to requesting STA.
673 */
674 lim_send_assoc_rsp_mgmt_frame(mac_ctx, result_code, 0, peer_addr,
bings85512332019-09-04 17:46:37 +0800675 sub_type, 0, session_entry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700677 if (session_entry->parsedAssocReq[sta_ds->assocId]) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 uint8_t *assoc_req_frame;
679
680 assoc_req_frame = (uint8_t *)((tpSirAssocReq) (session_entry->
681 parsedAssocReq[sta_ds->assocId]))->assocReqFrame;
682 /*
683 *Assoction confirmation is complete,
684 *free the copy of association request frame.
685 */
686 if (assoc_req_frame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530687 qdf_mem_free(assoc_req_frame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 assoc_req_frame = NULL;
689 }
690
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530691 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
693 }
694}
695
696/**
697 * lim_decide_ap_protection_on_ht20_delete() - function to update protection
698 * parameters.
699 * @mac_ctx: pointer to global mac structure
700 * @sta_ds: station node
701 * @beacon_params: ap beacon parameters
702 * @session_entry: pe session entry
703 *
704 * protection related function while HT20 station is getting deleted.
705 *
706 * Return: none
707 */
708static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800709lim_decide_ap_protection_on_ht20_delete(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 tpDphHashNode sta_ds,
711 tpUpdateBeaconParams beacon_params,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -0800712 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713{
714 uint32_t i = 0;
715
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700716 pe_debug("(%d) A HT 20 STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
717 session_entry->gLimHt20Params.numSta,
718 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
720 if (session_entry->gLimHt20Params.numSta > 0) {
721 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
722 if (!session_entry->protStaCache[i].active)
723 continue;
724
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530725 if (!qdf_mem_cmp(session_entry->protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726 sta_ds->staAddr, sizeof(tSirMacAddr))) {
727 session_entry->gLimHt20Params.numSta--;
728 session_entry->protStaCache[i].active =
729 false;
730 break;
731 }
732 }
733 }
734
735 if (session_entry->gLimHt20Params.numSta == 0) {
736 /* disable protection */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700737 pe_debug("No 11B STA exists, PESessionID %d",
738 session_entry->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 lim_enable_ht20_protection(mac_ctx, false, false, beacon_params,
740 session_entry);
741 }
742}
743
744/**
745 * lim_decide_ap_protection_on_delete() - update SAP protection on station
746 * deletion.
747 * @mac_ctx: pointer to global mac structure
748 * @sta_ds: station node
749 * @beacon_params: ap beacon parameters
750 * @session_entry: pe session entry
751 *
752 * Decides about protection related settings when a station is getting deleted.
753 *
754 * Return: none
755 */
756void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800757lim_decide_ap_protection_on_delete(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 tpDphHashNode sta_ds,
759 tpUpdateBeaconParams beacon_params,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -0800760 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761{
762 uint32_t phy_mode;
763 tHalBitVal erp_enabled = eHAL_CLEAR;
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800764 enum reg_wifi_band rf_band = REG_BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 uint32_t i;
766
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700767 if (!sta_ds)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 return;
769
770 lim_get_rf_band_new(mac_ctx, &rf_band, session_entry);
771 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
772 erp_enabled = sta_ds->erpEnabled;
773
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800774 if ((REG_BAND_5G == rf_band) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775 (true == session_entry->htCapability) &&
776 (session_entry->beaconParams.llaCoexist) &&
777 (false == sta_ds->mlmStaContext.htCapability)) {
778 /*
779 * we are HT. if we are 11A, then protection is not required or
780 * we are HT and 11A station is leaving.
781 * protection consideration required.
782 * HT station leaving ==> this case is commonly handled
783 * between both the bands below.
784 */
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700785 pe_debug("(%d) A 11A STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
786 session_entry->gLim11aParams.numSta,
787 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
789 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530790 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 session_entry->protStaCache[i].addr,
792 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530793 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 session_entry->protStaCache[i].active = false;
795 break;
796 }
797 }
798
799 if (session_entry->gLim11aParams.numSta == 0) {
800 /* disable protection */
801 lim_update_11a_protection(mac_ctx, false, false,
802 beacon_params, session_entry);
803 }
804 }
805
806 /* we are HT or 11G and 11B station is getting deleted */
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800807 if ((REG_BAND_2G == rf_band) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 (phy_mode == WNI_CFG_PHY_MODE_11G ||
809 session_entry->htCapability) &&
810 (erp_enabled == eHAL_CLEAR)) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700811 pe_debug("(%d) A legacy STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
812 session_entry->gLim11bParams.numSta,
813 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
815 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530816 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 session_entry->protStaCache[i].addr,
818 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530819 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 session_entry->gLim11bParams.numSta--;
821 session_entry->protStaCache[i].active =
822 false;
823 break;
824 }
825 }
826
827 if (session_entry->gLim11bParams.numSta == 0) {
828 /* disable protection */
829 lim_enable11g_protection(mac_ctx, false, false,
830 beacon_params, session_entry);
831 }
832 }
833
834 /*
835 * we are HT AP and non-11B station is leaving.
836 * 11g station is leaving
837 */
Amruta Kulkarni453c4e22019-11-20 10:59:21 -0800838 if ((REG_BAND_2G == rf_band) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 session_entry->htCapability &&
840 !sta_ds->mlmStaContext.htCapability) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700841 pe_debug("(%d) A 11g STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
842 session_entry->gLim11bParams.numSta,
843 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
845 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530846 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 session_entry->protStaCache[i].addr,
848 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530849 sizeof(tSirMacAddr)))) {
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -0700850 session_entry->gLim11gParams.numSta--;
851 session_entry->protStaCache[i].active = false;
852 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 }
854 }
855
856 if (session_entry->gLim11gParams.numSta == 0) {
857 /* disable protection */
858 lim_enable_ht_protection_from11g(mac_ctx, false, false,
859 beacon_params,
860 session_entry);
861 }
862 }
863
864 if (!((true == session_entry->htCapability) &&
865 (true == sta_ds->mlmStaContext.htCapability)))
866 return;
867
868 /*
869 * Applies to 2.4 as well as 5 GHZ.
870 * HT non-GF leaving
871 */
872 if (!sta_ds->htGreenfield) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700873 pe_debug("(%d) A non-GF STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
874 session_entry->gLimNonGfParams.numSta,
875 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
877 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530878 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 session_entry->protStaCache[i].addr,
880 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530881 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 session_entry->protStaCache[i].active = false;
883 break;
884 }
885 }
886
887 if (session_entry->gLimNonGfParams.numSta == 0) {
888 /* disable protection */
889 lim_enable_ht_non_gf_protection(mac_ctx, false, false,
890 beacon_params, session_entry);
891 }
892 }
893
894 /*
895 * Applies to 2.4 as well as 5 GHZ.
896 * HT 20Mhz station leaving
897 */
898 if (session_entry->beaconParams.ht20Coexist &&
899 (eHT_CHANNEL_WIDTH_20MHZ ==
900 sta_ds->htSupportedChannelWidthSet)) {
901 lim_decide_ap_protection_on_ht20_delete(mac_ctx, sta_ds,
902 beacon_params, session_entry);
903 }
904
905 /*
906 * Applies to 2.4 as well as 5 GHZ.
907 * LSIG TXOP not supporting staiton leaving
908 */
909 if ((false == session_entry->beaconParams.
910 fLsigTXOPProtectionFullSupport) &&
911 (false == sta_ds->htLsigTXOPProtection)) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700912 pe_debug("(%d) A HT LSIG not supporting STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 session_entry->gLimLsigTxopParams.numSta,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700914 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
916 if (session_entry->protStaCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530917 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 session_entry->protStaCache[i].addr,
919 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530920 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 session_entry->protStaCache[i].active = false;
922 break;
923 }
924 }
925
926 if (session_entry->gLimLsigTxopParams.numSta == 0) {
927 /* disable protection */
928 lim_enable_ht_lsig_txop_protection(mac_ctx, true,
929 false, beacon_params, session_entry);
930 }
931 }
932}
933
934/**
935 * lim_decide_short_preamble() - update short preamble parameters
936 * @mac_ctx: pointer to global mac structure
937 * @sta_ds: station node
938 * @beacon_params: ap beacon parameters
939 * @session_entry: pe session entry
940 *
941 * Decides about any short preamble related change because of new station
942 * joining.
943 *
944 * Return: None
945 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800946static void lim_decide_short_preamble(struct mac_context *mac_ctx,
Jeff Johnson72c8e7c2016-10-06 18:43:52 -0700947 tpDphHashNode sta_ds,
948 tpUpdateBeaconParams beacon_params,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -0800949 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950{
951 uint32_t i;
952
953 if (sta_ds->shortPreambleEnabled == eHAL_CLEAR) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -0700954 pe_debug("(%d) A non-short preamble STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
955 session_entry->gLimNoShortParams.numNonShortPreambleSta,
956 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
958 if (session_entry->gLimNoShortParams.
959 staNoShortCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530960 (!qdf_mem_cmp(session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 gLimNoShortParams.
962 staNoShortCache[i].addr,
963 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 session_entry->gLimNoShortParams.
966 numNonShortPreambleSta--;
967 session_entry->gLimNoShortParams.
968 staNoShortCache[i].active = false;
969 break;
970 }
971 }
972
973 if (session_entry->gLimNoShortParams.numNonShortPreambleSta)
974 return;
975
976 /*
977 * enable short preamble
978 * reset the cache
979 */
hangtian127c9532019-01-12 13:29:07 +0800980 qdf_mem_zero((uint8_t *) &session_entry->gLimNoShortParams,
981 sizeof(tLimNoShortParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 if (lim_enable_short_preamble(mac_ctx, true,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700983 beacon_params, session_entry) != QDF_STATUS_SUCCESS)
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -0700984 pe_err("Cannot enable short preamble");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 }
986}
987
988/**
989 * lim_decide_short_slot() - update short slot time related parameters
990 * @mac_ctx: pointer to global mac structure
991 * @sta_ds: station node
992 * @beacon_params: ap beacon parameters
993 * @session_entry: pe session entry
994 *
995 * Decides about any short slot time related change because of station leaving
996 * the BSS.
997 * Return: None
998 */
Jeff Johnson72c8e7c2016-10-06 18:43:52 -0700999static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001000lim_decide_short_slot(struct mac_context *mac_ctx, tpDphHashNode sta_ds,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 tpUpdateBeaconParams beacon_params,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -08001002 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003{
1004 uint32_t i, val, non_short_slot_sta_count;
1005
1006 if (sta_ds->shortSlotTimeEnabled != eHAL_CLEAR)
1007 return;
1008
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001009 pe_debug("(%d) A non-short slottime STA is disassociated. Addr is "QDF_MAC_ADDR_FMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07001011 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012
gaurank kathpaliae5a17e42018-09-10 10:05:25 +05301013 val = mac_ctx->mlme_cfg->feature_flags.enable_short_slot_time_11g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014
1015 if (LIM_IS_AP_ROLE(session_entry)) {
1016 non_short_slot_sta_count =
1017 session_entry->gLimNoShortSlotParams.numNonShortSlotSta;
1018 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1019 if (session_entry->gLimNoShortSlotParams.
1020 staNoShortSlotCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301021 (!qdf_mem_cmp(session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022 gLimNoShortSlotParams.
1023 staNoShortSlotCache[i].addr,
1024 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301025 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 non_short_slot_sta_count--;
1027 session_entry->gLimNoShortSlotParams.
1028 staNoShortSlotCache[i].active = false;
1029 break;
1030 }
1031 }
1032
1033 if (non_short_slot_sta_count == 0 && val) {
1034 /*
1035 * enable short slot time
1036 * reset the cache
1037 */
hangtian127c9532019-01-12 13:29:07 +08001038 qdf_mem_zero((uint8_t *) &session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 gLimNoShortSlotParams,
hangtian127c9532019-01-12 13:29:07 +08001040 sizeof(tLimNoShortSlotParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 beacon_params->fShortSlotTime = true;
1042 beacon_params->paramChangeBitmap |=
1043 PARAM_SHORT_SLOT_TIME_CHANGED;
1044 session_entry->shortSlotTimeSupported = true;
1045 }
1046 session_entry->gLimNoShortSlotParams.numNonShortSlotSta =
1047 non_short_slot_sta_count;
1048 } else {
1049 non_short_slot_sta_count =
1050 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta;
1051 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1052 if (mac_ctx->lim.gLimNoShortSlotParams.
1053 staNoShortSlotCache[i].active &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301054 (!qdf_mem_cmp(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 mac_ctx->lim.gLimNoShortSlotParams.
1056 staNoShortSlotCache[i].addr,
1057 sta_ds->staAddr,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301058 sizeof(tSirMacAddr)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 non_short_slot_sta_count--;
1060 mac_ctx->lim.gLimNoShortSlotParams.
1061 staNoShortSlotCache[i].active = false;
1062 break;
1063 }
1064 }
1065
1066 if (val && !non_short_slot_sta_count) {
1067 /*
1068 * enable short slot time
1069 * reset the cache
1070 */
hangtian127c9532019-01-12 13:29:07 +08001071 qdf_mem_zero(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 (uint8_t *) &mac_ctx->lim.gLimNoShortSlotParams,
hangtian127c9532019-01-12 13:29:07 +08001073 sizeof(tLimNoShortSlotParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 /*in case of AP set SHORT_SLOT_TIME to enable*/
1075 if (LIM_IS_AP_ROLE(session_entry)) {
1076 beacon_params->fShortSlotTime = true;
1077 beacon_params->paramChangeBitmap |=
1078 PARAM_SHORT_SLOT_TIME_CHANGED;
1079 session_entry->shortSlotTimeSupported = true;
1080 }
1081 }
1082 mac_ctx->lim.gLimNoShortSlotParams.numNonShortSlotSta =
1083 non_short_slot_sta_count;
1084 }
1085}
1086
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001087static uint8_t lim_get_nss_from_vht_mcs_map(uint16_t mcs_map)
1088{
1089 uint8_t nss = 0;
1090 uint16_t mcs_mask = 0x3;
1091
1092 for (nss = 0; nss < VHT_MAX_NSS; nss++) {
1093 if ((mcs_map & mcs_mask) == mcs_mask)
1094 return nss;
1095
1096 mcs_mask = (mcs_mask << 2);
1097 }
1098
1099 return nss;
1100}
1101
1102static void lim_get_vht_gt80_nss(struct mac_context *mac_ctx,
1103 struct sDphHashNode *sta_ds,
1104 tDot11fIEVHTCaps *vht_caps,
1105 struct pe_session *session)
1106{
1107 uint8_t nss;
1108
1109 if (!vht_caps->vht_extended_nss_bw_cap) {
1110 sta_ds->vht_160mhz_nss = 0;
1111 sta_ds->vht_80p80mhz_nss = 0;
1112 pe_debug("peer does not support vht extnd nss bw");
1113
1114 return;
1115 }
1116
1117 nss = lim_get_nss_from_vht_mcs_map(vht_caps->rxMCSMap);
1118
1119 if (!nss) {
1120 pe_debug("Invalid peer VHT MCS map %0X", vht_caps->rxMCSMap);
1121 nss = 1;
1122 }
1123
1124 switch (vht_caps->supportedChannelWidthSet) {
1125 case VHT_CAP_NO_160M_SUPP:
1126 if (vht_caps->extended_nss_bw_supp ==
1127 VHT_EXTD_NSS_80_HALF_NSS_160) {
1128 sta_ds->vht_160mhz_nss = nss / 2;
1129 sta_ds->vht_80p80mhz_nss = 0;
1130 } else if (vht_caps->extended_nss_bw_supp ==
1131 VHT_EXTD_NSS_80_HALF_NSS_80P80) {
1132 sta_ds->vht_160mhz_nss = nss / 2;
1133 sta_ds->vht_80p80mhz_nss = nss / 2;
1134 } else if (vht_caps->extended_nss_bw_supp ==
1135 VHT_EXTD_NSS_80_3QUART_NSS_80P80) {
1136 sta_ds->vht_160mhz_nss = (nss * 3) / 4;
1137 sta_ds->vht_80p80mhz_nss = (nss * 3) / 4;
1138 } else {
1139 sta_ds->vht_160mhz_nss = 0;
1140 sta_ds->vht_80p80mhz_nss = 0;
1141 }
1142 break;
1143 case VHT_CAP_160_SUPP:
1144 sta_ds->vht_160mhz_nss = nss;
1145 if (vht_caps->extended_nss_bw_supp ==
1146 VHT_EXTD_NSS_160_HALF_NSS_80P80) {
1147 sta_ds->vht_80p80mhz_nss = nss / 2;
1148 } else if (vht_caps->extended_nss_bw_supp ==
1149 VHT_EXTD_NSS_160_3QUART_NSS_80P80) {
1150 sta_ds->vht_80p80mhz_nss = (nss * 3) / 4;
1151 } else if (vht_caps->extended_nss_bw_supp ==
1152 VHT_EXTD_NSS_2X_NSS_160_1X_NSS_80P80) {
1153 if (nss > (VHT_MAX_NSS / 2)) {
1154 pe_debug("Invalid extnd nss bw support val");
1155 sta_ds->vht_80p80mhz_nss = nss / 2;
1156 break;
1157 }
1158 sta_ds->vht_160mhz_nss = nss * 2;
1159 if (session->nss == MAX_VDEV_NSS)
1160 break;
1161 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
1162 break;
1163 session->nss *= 2;
1164 } else {
1165 sta_ds->vht_80p80mhz_nss = 0;
1166 }
1167 break;
1168 case VHT_CAP_160_AND_80P80_SUPP:
1169 if (vht_caps->extended_nss_bw_supp ==
1170 VHT_EXTD_NSS_2X_NSS_80_1X_NSS_80P80) {
1171 if (nss > (VHT_MAX_NSS / 2)) {
1172 pe_debug("Invalid extnd nss bw support val");
1173 break;
1174 }
1175 if (session->nss == MAX_VDEV_NSS)
1176 break;
1177 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
1178 break;
1179 session->nss *= 2;
1180 } else {
1181 sta_ds->vht_160mhz_nss = nss;
1182 sta_ds->vht_80p80mhz_nss = nss;
1183 }
1184 break;
1185 default:
1186 sta_ds->vht_160mhz_nss = 0;
1187 sta_ds->vht_80p80mhz_nss = 0;
1188 }
1189 pe_debug("AP Nss config: 160MHz: %d, 80P80MHz %d",
1190 sta_ds->vht_160mhz_nss, sta_ds->vht_80p80mhz_nss);
1191 sta_ds->vht_160mhz_nss = QDF_MIN(sta_ds->vht_160mhz_nss, session->nss);
1192 sta_ds->vht_80p80mhz_nss = QDF_MIN(sta_ds->vht_80p80mhz_nss,
1193 session->nss);
1194 pe_debug("Session Nss config: 160MHz: %d, 80P80MHz %d, session Nss %d",
1195 sta_ds->vht_160mhz_nss, sta_ds->vht_80p80mhz_nss,
1196 session->nss);
1197}
1198
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001199QDF_STATUS lim_populate_vht_mcs_set(struct mac_context *mac_ctx,
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001200 struct supported_rates *rates,
1201 tDot11fIEVHTCaps *peer_vht_caps,
1202 struct pe_session *session_entry,
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001203 uint8_t nss,
1204 struct sDphHashNode *sta_ds)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206 uint32_t self_sta_dot11mode = 0;
1207 uint16_t mcs_map_mask = MCSMAPMASK1x1;
1208 uint16_t mcs_map_mask2x2 = 0;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05301209 struct mlme_vht_capabilities_info *vht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210
gaurank kathpalia1be77fa2019-01-04 13:32:09 +05301211 self_sta_dot11mode = mac_ctx->mlme_cfg->dot11_mode.dot11_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212
1213 if (!IS_DOT11_MODE_VHT(self_sta_dot11mode))
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001214 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001216 if (!peer_vht_caps || !peer_vht_caps->present)
1217 return QDF_STATUS_SUCCESS;
1218
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05301219 vht_cap_info = &mac_ctx->mlme_cfg->vht_caps.vht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05301221 rates->vhtRxMCSMap = (uint16_t)vht_cap_info->rx_mcs_map;
1222 rates->vhtTxMCSMap = (uint16_t)vht_cap_info->tx_mcs_map;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301223 rates->vhtRxHighestDataRate =
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05301224 (uint16_t)vht_cap_info->rx_supp_data_rate;
1225 rates->vhtTxHighestDataRate =
1226 (uint16_t)vht_cap_info->tx_supp_data_rate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001228 if (NSS_1x1_MODE == nss) {
1229 rates->vhtRxMCSMap |= VHT_MCS_1x1;
1230 rates->vhtTxMCSMap |= VHT_MCS_1x1;
1231 rates->vhtTxHighestDataRate =
1232 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
1233 rates->vhtRxHighestDataRate =
1234 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
Krunal Soni3e4a3b62018-05-03 14:09:47 -07001235 if (session_entry && !session_entry->ch_width &&
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05301236 !vht_cap_info->enable_vht20_mcs9 &&
Abhinav Kumare057b412018-10-09 17:28:16 +05301237 ((rates->vhtRxMCSMap & VHT_1x1_MCS_MASK) ==
Kiran Kumar Lokere0e255172018-03-30 18:54:25 -07001238 VHT_1x1_MCS9_MAP)) {
1239 DISABLE_VHT_MCS_9(rates->vhtRxMCSMap,
1240 NSS_1x1_MODE);
1241 DISABLE_VHT_MCS_9(rates->vhtTxMCSMap,
1242 NSS_1x1_MODE);
1243 }
1244 } else {
Krunal Soni3e4a3b62018-05-03 14:09:47 -07001245 if (session_entry && !session_entry->ch_width &&
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05301246 !vht_cap_info->enable_vht20_mcs9 &&
1247 ((rates->vhtRxMCSMap & VHT_2x2_MCS_MASK) ==
1248 VHT_2x2_MCS9_MAP)) {
Kiran Kumar Lokere0e255172018-03-30 18:54:25 -07001249 DISABLE_VHT_MCS_9(rates->vhtRxMCSMap,
1250 NSS_2x2_MODE);
1251 DISABLE_VHT_MCS_9(rates->vhtTxMCSMap,
1252 NSS_2x2_MODE);
1253 }
Kiran Kumar Lokere6671abd2016-05-02 19:36:19 -07001254 }
1255
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 rates->vhtTxHighestDataRate =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301257 QDF_MIN(rates->vhtTxHighestDataRate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 peer_vht_caps->txSupDataRate);
1259 rates->vhtRxHighestDataRate =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301260 QDF_MIN(rates->vhtRxHighestDataRate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 peer_vht_caps->rxHighSupDataRate);
1262
Abhishek Singhb01ac952017-08-17 13:52:23 +05301263 if (session_entry && session_entry->nss == NSS_2x2_MODE)
1264 mcs_map_mask2x2 = MCSMAPMASK2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265
1266 if ((peer_vht_caps->txMCSMap & mcs_map_mask) <
1267 (rates->vhtRxMCSMap & mcs_map_mask)) {
1268 rates->vhtRxMCSMap &= ~(mcs_map_mask);
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001269 rates->vhtRxMCSMap |= (peer_vht_caps->txMCSMap & mcs_map_mask);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 }
1271 if ((peer_vht_caps->rxMCSMap & mcs_map_mask) <
1272 (rates->vhtTxMCSMap & mcs_map_mask)) {
1273 rates->vhtTxMCSMap &= ~(mcs_map_mask);
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001274 rates->vhtTxMCSMap |= (peer_vht_caps->rxMCSMap & mcs_map_mask);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 }
1276
1277 if (mcs_map_mask2x2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 uint16_t peer_mcs_map, self_mcs_map;
1279
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001280 peer_mcs_map = peer_vht_caps->txMCSMap & mcs_map_mask2x2;
1281 self_mcs_map = rates->vhtRxMCSMap & mcs_map_mask2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282
1283 if ((self_mcs_map != mcs_map_mask2x2) &&
1284 ((peer_mcs_map == mcs_map_mask2x2) ||
1285 (peer_mcs_map < self_mcs_map))) {
1286 rates->vhtRxMCSMap &= ~mcs_map_mask2x2;
1287 rates->vhtRxMCSMap |= peer_mcs_map;
1288 }
1289
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001290 peer_mcs_map = (peer_vht_caps->rxMCSMap & mcs_map_mask2x2);
1291 self_mcs_map = (rates->vhtTxMCSMap & mcs_map_mask2x2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292
1293 if ((self_mcs_map != mcs_map_mask2x2) &&
1294 ((peer_mcs_map == mcs_map_mask2x2) ||
1295 (peer_mcs_map < self_mcs_map))) {
1296 rates->vhtTxMCSMap &= ~mcs_map_mask2x2;
1297 rates->vhtTxMCSMap |= peer_mcs_map;
1298 }
1299 }
Abhishek Singh3be6fab2020-02-06 12:28:33 +05301300
1301 pe_debug("RxMCSMap %x TxMCSMap %x", rates->vhtRxMCSMap,
1302 rates->vhtTxMCSMap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001304 if (!session_entry)
1305 return QDF_STATUS_SUCCESS;
1306
1307 session_entry->supported_nss_1x1 =
1308 ((rates->vhtTxMCSMap & VHT_MCS_1x1) == VHT_MCS_1x1) ?
1309 true : false;
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001310
1311 if (!sta_ds || CH_WIDTH_80MHZ >= session_entry->ch_width)
1312 return QDF_STATUS_SUCCESS;
1313
1314 sta_ds->vht_extended_nss_bw_cap =
1315 peer_vht_caps->vht_extended_nss_bw_cap;
1316 lim_get_vht_gt80_nss(mac_ctx, sta_ds, peer_vht_caps, session_entry);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001317
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001318 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320
Abhishek Singh3be6fab2020-02-06 12:28:33 +05301321static void lim_dump_ht_mcs_mask(uint8_t *self_mcs, uint8_t *peer_mcs)
1322{
1323 uint32_t len = 0;
1324 uint8_t idx;
1325 uint8_t *buff;
1326 uint32_t buff_len;
1327
1328 /*
1329 * Buffer of (SIR_MAC_MAX_SUPPORTED_MCS_SET * 5) + 1 to consider the 4
1330 * char MCS eg 0xff and 1 space after it and 1 to end the string with
1331 * NULL.
1332 */
1333 buff_len = (SIR_MAC_MAX_SUPPORTED_MCS_SET * 5) + 1;
1334 buff = qdf_mem_malloc(buff_len);
1335 if (!buff)
1336 return;
1337
1338 if (self_mcs) {
1339 for (idx = 0; idx < SIR_MAC_MAX_SUPPORTED_MCS_SET; idx++)
1340 len += qdf_scnprintf(buff + len, buff_len - len,
1341 "0x%x ", self_mcs[idx]);
1342
1343 pe_nofl_debug("SELF HT MCS: %s", buff);
1344 }
1345
1346 if (peer_mcs) {
1347 len = 0;
1348 for (idx = 0; idx < SIR_MAC_MAX_SUPPORTED_MCS_SET; idx++)
1349 len += qdf_scnprintf(buff + len, buff_len - len,
1350 "0x%x ", peer_mcs[idx]);
1351
1352 pe_nofl_debug("PEER HT MCS: %s", buff);
1353 }
1354
1355 qdf_mem_free(buff);
1356}
1357
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001358QDF_STATUS lim_populate_own_rate_set(struct mac_context *mac_ctx,
1359 struct supported_rates *rates,
1360 uint8_t *supported_mcs_set,
1361 uint8_t basic_only,
1362 struct pe_session *session_entry,
1363 struct sDot11fIEVHTCaps *vht_caps,
1364 struct sDot11fIEhe_cap *he_caps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365{
1366 tSirMacRateSet temp_rate_set;
1367 tSirMacRateSet temp_rate_set2;
1368 uint32_t i, j, val, min, is_arate;
1369 uint32_t phy_mode = 0;
1370 uint32_t self_sta_dot11mode = 0;
1371 uint8_t a_rate_index = 0;
1372 uint8_t b_rate_index = 0;
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301373 qdf_size_t val_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 is_arate = 0;
1376
gaurank kathpalia1be77fa2019-01-04 13:32:09 +05301377 self_sta_dot11mode = mac_ctx->mlme_cfg->dot11_mode.dot11_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1379
1380 /*
1381 * Include 11b rates only when the device configured in
1382 * auto, 11a/b/g or 11b_only
1383 */
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301384 if ((self_sta_dot11mode == MLME_DOT11_MODE_ALL) ||
1385 (self_sta_dot11mode == MLME_DOT11_MODE_11A) ||
1386 (self_sta_dot11mode == MLME_DOT11_MODE_11AC) ||
1387 (self_sta_dot11mode == MLME_DOT11_MODE_11N) ||
1388 (self_sta_dot11mode == MLME_DOT11_MODE_11G) ||
Abhishek Ambure5ec0d662019-11-12 17:31:26 +05301389 (self_sta_dot11mode == MLME_DOT11_MODE_11B) ||
1390 (self_sta_dot11mode == MLME_DOT11_MODE_11AX)) {
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301391 val_len = mac_ctx->mlme_cfg->rates.supported_11b.len;
1392 wlan_mlme_get_cfg_str((uint8_t *)&temp_rate_set.rate,
1393 &mac_ctx->mlme_cfg->rates.supported_11b,
1394 &val_len);
1395 temp_rate_set.numRates = (uint8_t)val_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 } else {
1397 temp_rate_set.numRates = 0;
1398 }
1399
1400 /* Include 11a rates when the device configured in non-11b mode */
1401 if (!IS_DOT11_MODE_11B(self_sta_dot11mode)) {
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301402 val_len = mac_ctx->mlme_cfg->rates.supported_11a.len;
1403 wlan_mlme_get_cfg_str((uint8_t *)&temp_rate_set2.rate,
1404 &mac_ctx->mlme_cfg->rates.supported_11a,
1405 &val_len);
1406 temp_rate_set2.numRates = (uint8_t)val_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 } else {
1408 temp_rate_set2.numRates = 0;
1409 }
1410
1411 if ((temp_rate_set.numRates + temp_rate_set2.numRates) > 12) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001412 pe_err("more than 12 rates in CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001413 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 }
1415 /* copy all rates in temp_rate_set, there are 12 rates max */
1416 for (i = 0; i < temp_rate_set2.numRates; i++)
1417 temp_rate_set.rate[i + temp_rate_set.numRates] =
1418 temp_rate_set2.rate[i];
1419
1420 temp_rate_set.numRates += temp_rate_set2.numRates;
1421
1422 /**
1423 * Sort rates in temp_rate_set (they are likely to be already sorted)
1424 * put the result in pSupportedRates
1425 */
1426
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001427 qdf_mem_zero(rates, sizeof(*rates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 for (i = 0; i < temp_rate_set.numRates; i++) {
1429 min = 0;
1430 val = 0xff;
1431 is_arate = 0;
1432
1433 for (j = 0; (j < temp_rate_set.numRates) &&
Srinivas Girigowda61771262019-04-01 11:55:19 -07001434 (j < WLAN_SUPPORTED_RATES_IE_MAX_LEN); j++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 if ((uint32_t) (temp_rate_set.rate[j] & 0x7f) <
1436 val) {
1437 val = temp_rate_set.rate[j] & 0x7f;
1438 min = j;
1439 }
1440 }
1441
1442 if (sirIsArate(temp_rate_set.rate[min] & 0x7f))
1443 is_arate = 1;
1444
Kiran Kumar Lokereb503c7c2018-05-03 16:24:53 -07001445 if (is_arate)
1446 rates->llaRates[a_rate_index++] =
1447 temp_rate_set.rate[min];
1448 else
1449 rates->llbRates[b_rate_index++] =
1450 temp_rate_set.rate[min];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451 temp_rate_set.rate[min] = 0xff;
1452 }
1453
1454 if (IS_DOT11_MODE_HT(self_sta_dot11mode)) {
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301455 val_len = SIZE_OF_SUPPORTED_MCS_SET;
1456 if (wlan_mlme_get_cfg_str(
1457 rates->supportedMCSSet,
1458 &mac_ctx->mlme_cfg->rates.supported_mcs_set,
1459 &val_len) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001460 pe_err("could not retrieve supportedMCSSet");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001461 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 }
1463
Arif Hussain74fc5712016-07-20 11:10:01 -07001464 if (session_entry->nss == NSS_1x1_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001465 rates->supportedMCSSet[1] = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 /*
1467 * if supported MCS Set of the peer is passed in,
1468 * then do the intersection
1469 * else use the MCS set from local CFG.
1470 */
1471
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001472 if (supported_mcs_set) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1474 rates->supportedMCSSet[i] &=
1475 supported_mcs_set[i];
1476 }
1477
Abhishek Singh3be6fab2020-02-06 12:28:33 +05301478 lim_dump_ht_mcs_mask(rates->supportedMCSSet, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 }
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001480 lim_populate_vht_mcs_set(mac_ctx, rates, vht_caps, session_entry,
1481 session_entry->nss, NULL);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001482 lim_populate_he_mcs_set(mac_ctx, rates, he_caps,
1483 session_entry, session_entry->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001485 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486}
1487
Naveen Rawatcbcc6542017-10-30 17:55:03 -07001488#ifdef WLAN_FEATURE_11AX
1489/**
1490 * lim_calculate_he_nss() - function to calculate new nss from he rates
1491 * @rates: supported rtes struct object
1492 * @session: pe session entry
1493 * This function calculates nss from rx_he_mcs_map_lt_80 within rates struct
1494 * object and assigns new value to nss within pe_session
1495 *
1496 * Return: None
1497 */
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001498static void lim_calculate_he_nss(struct supported_rates *rates,
1499 struct pe_session *session)
Naveen Rawatcbcc6542017-10-30 17:55:03 -07001500{
1501 HE_GET_NSS(rates->rx_he_mcs_map_lt_80, session->nss);
1502}
Kiran Kumar Lokere2f8a3602019-11-21 17:40:06 -08001503
1504static bool lim_check_valid_mcs_for_nss(struct pe_session *session,
1505 tDot11fIEhe_cap *he_caps)
1506{
1507 uint16_t mcs_map;
1508 uint8_t mcs_count = 2, i;
1509
Kiran Kumar Lokere8b44a512020-05-11 19:02:32 -07001510 if (!session->he_capable || !he_caps || !he_caps->present)
Kiran Kumar Lokere2f8a3602019-11-21 17:40:06 -08001511 return true;
1512
1513 mcs_map = he_caps->rx_he_mcs_map_lt_80;
1514
1515 do {
1516 for (i = 0; i < session->nss; i++) {
1517 if (((mcs_map >> (i * 2)) & 0x3) == 0x3)
1518 return false;
1519 }
1520
1521 mcs_map = he_caps->tx_he_mcs_map_lt_80;
1522 mcs_count--;
1523 } while (mcs_count);
1524
1525 return true;
1526
1527}
Naveen Rawatcbcc6542017-10-30 17:55:03 -07001528#else
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001529static void lim_calculate_he_nss(struct supported_rates *rates,
1530 struct pe_session *session)
Naveen Rawatcbcc6542017-10-30 17:55:03 -07001531{
1532}
Kiran Kumar Lokere2f8a3602019-11-21 17:40:06 -08001533
1534static bool lim_check_valid_mcs_for_nss(struct pe_session *session,
1535 tDot11fIEhe_cap *he_caps)
1536{
1537 return true;
1538}
Naveen Rawatcbcc6542017-10-30 17:55:03 -07001539#endif
1540
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001541QDF_STATUS lim_populate_peer_rate_set(struct mac_context *mac,
1542 struct supported_rates *pRates,
1543 uint8_t *pSupportedMCSSet,
1544 uint8_t basicOnly,
1545 struct pe_session *pe_session,
1546 tDot11fIEVHTCaps *pVHTCaps,
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001547 tDot11fIEhe_cap *he_caps,
Pragaspathi Thilagaraj4af0b252020-07-16 19:54:53 +05301548 struct sDphHashNode *sta_ds,
1549 struct bss_description *bss_desc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550{
1551 tSirMacRateSet tempRateSet;
1552 tSirMacRateSet tempRateSet2;
android-t2591808b2022-12-02 16:02:26 +08001553 uint32_t i, j, val, min;
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301554 qdf_size_t val_len;
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001555 uint8_t aRateIndex = 0;
1556 uint8_t bRateIndex = 0;
Kiran Kumar Lokere2f8a3602019-11-21 17:40:06 -08001557 tDot11fIEhe_cap *peer_he_caps;
Kiran Kumar Lokeree8ef2ca2019-12-30 16:31:09 -08001558 tSchBeaconStruct *pBeaconStruct = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001560 /* copy operational rate set from pe_session */
Srinivas Girigowda61771262019-04-01 11:55:19 -07001561 if (pe_session->rateSet.numRates <= WLAN_SUPPORTED_RATES_IE_MAX_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301562 qdf_mem_copy((uint8_t *) tempRateSet.rate,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001563 (uint8_t *) (pe_session->rateSet.rate),
1564 pe_session->rateSet.numRates);
1565 tempRateSet.numRates = pe_session->rateSet.numRates;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 } else {
Srinivas Girigowda61771262019-04-01 11:55:19 -07001567 pe_err("more than WLAN_SUPPORTED_RATES_IE_MAX_LEN rates");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001568 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 }
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301570 if ((pe_session->dot11mode == MLME_DOT11_MODE_11G) ||
1571 (pe_session->dot11mode == MLME_DOT11_MODE_11A) ||
1572 (pe_session->dot11mode == MLME_DOT11_MODE_11AC) ||
Abhishek Ambure5ec0d662019-11-12 17:31:26 +05301573 (pe_session->dot11mode == MLME_DOT11_MODE_11N) ||
1574 (pe_session->dot11mode == MLME_DOT11_MODE_11AX)) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001575 if (pe_session->extRateSet.numRates <=
Srinivas Girigowda61771262019-04-01 11:55:19 -07001576 WLAN_SUPPORTED_RATES_IE_MAX_LEN) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 qdf_mem_copy((uint8_t *) tempRateSet2.rate,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001578 (uint8_t *) (pe_session->extRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 rate),
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001580 pe_session->extRateSet.numRates);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 tempRateSet2.numRates =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001582 pe_session->extRateSet.numRates;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 } else {
Srinivas Girigowda61771262019-04-01 11:55:19 -07001584 pe_err("pe_session->extRateSet.numRates more than WLAN_SUPPORTED_RATES_IE_MAX_LEN rates");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001585 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 }
1587 } else
1588 tempRateSet2.numRates = 0;
gaurank kathpaliafaf302c2018-07-12 16:07:16 +05301589 if ((tempRateSet.numRates + tempRateSet2.numRates) >
Srinivas Girigowda61771262019-04-01 11:55:19 -07001590 WLAN_SUPPORTED_RATES_IE_MAX_LEN) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001591 pe_err("more than 12 rates in CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001592 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 }
1594
1595 /* copy all rates in tempRateSet, there are 12 rates max */
1596 for (i = 0; i < tempRateSet2.numRates; i++)
1597 tempRateSet.rate[i + tempRateSet.numRates] =
1598 tempRateSet2.rate[i];
1599 tempRateSet.numRates += tempRateSet2.numRates;
1600 /**
1601 * Sort rates in tempRateSet (they are likely to be already sorted)
1602 * put the result in pSupportedRates
1603 */
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001604
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001605 qdf_mem_zero(pRates, sizeof(*pRates));
1606 for (i = 0; i < tempRateSet.numRates; i++) {
1607 min = 0;
1608 val = 0xff;
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001609 for (j = 0; (j < tempRateSet.numRates) &&
1610 (j < WLAN_SUPPORTED_RATES_IE_MAX_LEN); j++) {
1611 if ((uint32_t)(tempRateSet.rate[j] & 0x7f) <
1612 val) {
1613 val = tempRateSet.rate[j] & 0x7f;
1614 min = j;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 }
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001616 }
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001617 /*
1618 * HAL needs to know whether the rate is basic rate or not,
1619 * as it needs to update the response rate table accordingly.
1620 * e.g. if one of the 11a rates is basic rate, then that rate
1621 * can be used for sending control frames. HAL updates the
1622 * response rate table whenever basic rate set is changed.
1623 */
android-t2591808b2022-12-02 16:02:26 +08001624 if (basicOnly && !(tempRateSet.rate[min] & 0x80)) {
1625 pe_debug("Invalid basic rate");
1626 } else if (sirIsArate(tempRateSet.rate[min] & 0x7f)) {
1627 if (aRateIndex >= SIR_NUM_11A_RATES) {
1628 pe_debug("OOB, aRateIndex: %d", aRateIndex);
1629 } else if (aRateIndex >= 1 && (tempRateSet.rate[min] ==
1630 pRates->llaRates[aRateIndex - 1])) {
1631 pe_debug("Duplicate 11a rate: %d",
1632 tempRateSet.rate[min]);
1633 } else {
1634 pRates->llaRates[aRateIndex++] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 tempRateSet.rate[min];
android-t2591808b2022-12-02 16:02:26 +08001636 }
1637 } else if (sirIsBrate(tempRateSet.rate[min] & 0x7f)) {
1638 if (bRateIndex >= SIR_NUM_11B_RATES) {
1639 pe_debug("OOB, bRateIndex: %d", bRateIndex);
1640 } else if (bRateIndex >= 1 && (tempRateSet.rate[min] ==
1641 pRates->llbRates[bRateIndex - 1])) {
1642 pe_debug("Duplicate 11b rate: %d",
1643 tempRateSet.rate[min]);
1644 } else {
1645 pRates->llbRates[bRateIndex++] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 tempRateSet.rate[min];
1647 }
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001648 } else {
android-t2591808b2022-12-02 16:02:26 +08001649 pe_debug("%d is neither 11a nor 11b rate",
1650 tempRateSet.rate[min]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 }
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001652 tempRateSet.rate[min] = 0xff;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 }
1654
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08001655 if (IS_DOT11_MODE_HT(pe_session->dot11mode) &&
1656 !lim_is_he_6ghz_band(pe_session)) {
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301657 val_len = SIZE_OF_SUPPORTED_MCS_SET;
1658 if (wlan_mlme_get_cfg_str(
1659 pRates->supportedMCSSet,
Jeff Johnsonab322b92018-11-21 23:10:49 -08001660 &mac->mlme_cfg->rates.supported_mcs_set,
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301661 &val_len) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001662 pe_err("could not retrieve supportedMCSSet");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001663 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001665 if (pe_session->nss == NSS_1x1_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001666 pRates->supportedMCSSet[1] = 0;
1667
1668 /* if supported MCS Set of the peer is passed in, then do the
1669 * intersection, else use the MCS set from local CFG.
1670 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001671 if (pSupportedMCSSet) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 for (i = 0; i < SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1673 pRates->supportedMCSSet[i] &=
1674 pSupportedMCSSet[i];
1675 }
Abhishek Singh3be6fab2020-02-06 12:28:33 +05301676
1677 lim_dump_ht_mcs_mask(NULL, pRates->supportedMCSSet);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001678
Naveen Rawat64176682017-06-14 14:28:37 -07001679 if (pRates->supportedMCSSet[0] == 0) {
1680 pe_debug("Incorrect MCS 0 - 7. They must be supported");
1681 pRates->supportedMCSSet[0] = 0xFF;
1682 }
1683
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001684 pe_session->supported_nss_1x1 =
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001685 ((pRates->supportedMCSSet[1] != 0) ? false : true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 }
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001687 lim_populate_vht_mcs_set(mac, pRates, pVHTCaps, pe_session,
1688 pe_session->nss, sta_ds);
Naveen Rawat746a90b2017-06-07 15:16:35 -07001689
Kiran Kumar Lokere2f8a3602019-11-21 17:40:06 -08001690 if (lim_check_valid_mcs_for_nss(pe_session, he_caps)) {
1691 peer_he_caps = he_caps;
1692 } else {
Pragaspathi Thilagaraj4af0b252020-07-16 19:54:53 +05301693 if (!bss_desc) {
Gururaj Pandurangi645d78a2020-07-10 13:05:38 -07001694 pe_err("bssDescription is NULL");
1695 return QDF_STATUS_E_INVAL;
1696 }
Kiran Kumar Lokere2f8a3602019-11-21 17:40:06 -08001697 pBeaconStruct = qdf_mem_malloc(sizeof(tSchBeaconStruct));
1698 if (!pBeaconStruct)
1699 return QDF_STATUS_E_NOMEM;
Pragaspathi Thilagaraj4af0b252020-07-16 19:54:53 +05301700
1701 lim_extract_ap_capabilities(
1702 mac, (uint8_t *)bss_desc->ieFields,
1703 lim_get_ielen_from_bss_description(bss_desc),
Kiran Kumar Lokere2f8a3602019-11-21 17:40:06 -08001704 pBeaconStruct);
1705 peer_he_caps = &pBeaconStruct->he_cap;
1706 }
1707
1708 lim_populate_he_mcs_set(mac, pRates, peer_he_caps,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001709 pe_session, pe_session->nss);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001710
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001711 if (IS_DOT11_MODE_HE(pe_session->dot11mode) && he_caps) {
1712 lim_calculate_he_nss(pRates, pe_session);
Abhinav Kumar2ae25242020-05-11 22:46:11 +05301713 } else if (pe_session->vhtCapability) {
Naveen Rawat746a90b2017-06-07 15:16:35 -07001714 if ((pRates->vhtRxMCSMap & MCSMAPMASK2x2) == MCSMAPMASK2x2)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001715 pe_session->nss = NSS_1x1_MODE;
Naveen Rawat746a90b2017-06-07 15:16:35 -07001716 } else if (pRates->supportedMCSSet[1] == 0) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001717 pe_session->nss = NSS_1x1_MODE;
Naveen Rawat746a90b2017-06-07 15:16:35 -07001718 }
Abhishek Singh3be6fab2020-02-06 12:28:33 +05301719 pe_debug("nss 1x1 %d nss %d", pe_session->supported_nss_1x1,
1720 pe_session->nss);
Naveen Rawat746a90b2017-06-07 15:16:35 -07001721
Kiran Kumar Lokeree8ef2ca2019-12-30 16:31:09 -08001722 if (pBeaconStruct)
1723 qdf_mem_free(pBeaconStruct);
1724
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001725 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726} /*** lim_populate_peer_rate_set() ***/
1727
1728/**
1729 * lim_populate_matching_rate_set() -process the CFG rate sets and
1730 * the rate sets received in the Assoc request on AP.
1731 * @mac_ctx: pointer to global mac structure
1732 * @sta_ds: station node
1733 * @oper_rate_set: pointer to operating rate set
1734 * @ext_rate_set: pointer to extended rate set
1735 * @supported_mcs_set: pointer to supported rate set
1736 * @session_entry: pointer to pe session entry
1737 * @vht_caps: pointer to vht capabilities
1738 *
1739 * This is called at the time of Association Request
1740 * processing on AP and while adding peer's context
1741 * in IBSS role to process the CFG rate sets and
1742 * the rate sets received in the Assoc request on AP
1743 * or Beacon/Probe Response from peer in IBSS.
1744 *
1745 * 1. It makes the intersection between our own rate Sat
1746 * and extemcded rate set and the ones received in the
1747 * association request.
1748 * 2. It creates a combined rate set of 12 rates max which
1749 * comprised the basic and extended rates
1750 * 3. It sorts the combined rate Set and copy it in the
1751 * rate array of the pSTA descriptor
1752 *
1753 * The parser has already ensured unicity of the rates in the
1754 * association request structure
1755 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001756 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS_E_FAILURE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001758QDF_STATUS lim_populate_matching_rate_set(struct mac_context *mac_ctx,
Jeff Johnson81ae4282019-01-06 11:18:00 -08001759 tpDphHashNode sta_ds,
1760 tSirMacRateSet *oper_rate_set,
1761 tSirMacRateSet *ext_rate_set,
1762 uint8_t *supported_mcs_set,
1763 struct pe_session *session_entry,
1764 tDot11fIEVHTCaps *vht_caps,
1765 tDot11fIEhe_cap *he_caps)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766{
1767 tSirMacRateSet temp_rate_set;
1768 tSirMacRateSet temp_rate_set2;
1769 uint32_t i, j, val, min, is_arate;
1770 uint32_t phy_mode;
1771 uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET];
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001772 struct supported_rates *rates;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 uint8_t a_rate_index = 0;
1774 uint8_t b_rate_index = 0;
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301775 qdf_size_t val_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776
1777 is_arate = 0;
1778
1779 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1780
1781 /* copy operational rate set from session_entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301782 qdf_mem_copy((temp_rate_set.rate), (session_entry->rateSet.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 session_entry->rateSet.numRates);
1784 temp_rate_set.numRates = (uint8_t) session_entry->rateSet.numRates;
1785
1786 if (phy_mode == WNI_CFG_PHY_MODE_11G) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301787 qdf_mem_copy((temp_rate_set2.rate),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 (session_entry->extRateSet.rate),
1789 session_entry->extRateSet.numRates);
1790 temp_rate_set2.numRates =
1791 (uint8_t) session_entry->extRateSet.numRates;
1792 } else {
1793 temp_rate_set2.numRates = 0;
1794 }
1795
Naveen Rawat24c16912016-11-17 11:28:40 -08001796 /*
1797 * absolute sum of both num_rates should be less than 12. following
1798 * 16-bit sum avoids false codition where 8-bit arthematic overflow
1799 * might have caused total sum to be less than 12
1800 */
1801 if (((uint16_t)temp_rate_set.numRates +
1802 (uint16_t)temp_rate_set2.numRates) > 12) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001803 pe_err("more than 12 rates in CFG");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001804 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 }
1806
1807 /*
1808 * Handling of the rate set IEs is the following:
1809 * - keep only rates that we support and that the station supports
1810 * - sort and the rates into the pSta->rate array
1811 */
1812
1813 /* Copy all rates in temp_rate_set, there are 12 rates max */
1814 for (i = 0; i < temp_rate_set2.numRates; i++)
1815 temp_rate_set.rate[i + temp_rate_set.numRates] =
1816 temp_rate_set2.rate[i];
1817
1818 temp_rate_set.numRates += temp_rate_set2.numRates;
1819
1820 /*
1821 * Sort rates in temp_rate_set (they are likely to be already sorted)
1822 * put the result in temp_rate_set2
1823 */
1824 temp_rate_set2.numRates = 0;
1825
1826 for (i = 0; i < temp_rate_set.numRates; i++) {
1827 min = 0;
1828 val = 0xff;
1829
1830 for (j = 0; j < temp_rate_set.numRates; j++)
1831 if ((uint32_t) (temp_rate_set.rate[j] & 0x7f) < val) {
1832 val = temp_rate_set.rate[j] & 0x7f;
1833 min = j;
1834 }
1835
1836 temp_rate_set2.rate[temp_rate_set2.numRates++] =
1837 temp_rate_set.rate[min];
1838 temp_rate_set.rate[min] = 0xff;
1839 }
1840
1841 /*
1842 * Copy received rates in temp_rate_set, the parser has ensured
1843 * unicity of the rates so there cannot be more than 12
1844 */
1845 for (i = 0; (i < oper_rate_set->numRates &&
Srinivas Girigowda61771262019-04-01 11:55:19 -07001846 i < WLAN_SUPPORTED_RATES_IE_MAX_LEN); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 temp_rate_set.rate[i] = oper_rate_set->rate[i];
1848
1849 temp_rate_set.numRates = oper_rate_set->numRates;
1850
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001851 pe_debug("Sum of SUPPORTED and EXTENDED Rate Set (%1d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 temp_rate_set.numRates + ext_rate_set->numRates);
1853
1854 if (ext_rate_set->numRates &&
1855 ((temp_rate_set.numRates + ext_rate_set->numRates) > 12) &&
1856 temp_rate_set.numRates < 12) {
1857 int found = 0;
1858 int tail = temp_rate_set.numRates;
1859
1860 for (i = 0; (i < ext_rate_set->numRates &&
Srinivas Girigowda61771262019-04-01 11:55:19 -07001861 i < WLAN_SUPPORTED_RATES_IE_MAX_LEN); i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 found = 0;
1863 for (j = 0; j < (uint32_t) tail; j++) {
1864 if ((temp_rate_set.rate[j] & 0x7F) ==
1865 (ext_rate_set->rate[i] & 0x7F)) {
1866 found = 1;
1867 break;
1868 }
1869 }
1870
1871 if (!found) {
1872 temp_rate_set.rate[temp_rate_set.numRates++] =
1873 ext_rate_set->rate[i];
1874 if (temp_rate_set.numRates >= 12)
1875 break;
1876 }
1877 }
1878 } else if (ext_rate_set->numRates &&
1879 ((temp_rate_set.numRates + ext_rate_set->numRates) <= 12)) {
1880 for (j = 0; ((j < ext_rate_set->numRates) &&
Srinivas Girigowda61771262019-04-01 11:55:19 -07001881 (j < WLAN_SUPPORTED_RATES_IE_MAX_LEN) &&
1882 ((i + j) < WLAN_SUPPORTED_RATES_IE_MAX_LEN)); j++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 temp_rate_set.rate[i + j] = ext_rate_set->rate[j];
1884
1885 temp_rate_set.numRates += ext_rate_set->numRates;
1886 } else if (ext_rate_set->numRates) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001887 pe_debug("Relying only on the SUPPORTED Rate Set IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 }
1889
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 rates = &sta_ds->supportedRates;
Jeff Johnsonecd4f212019-02-01 19:36:34 -08001891 qdf_mem_zero(rates, sizeof(*rates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 for (i = 0; (i < temp_rate_set2.numRates &&
Srinivas Girigowda61771262019-04-01 11:55:19 -07001893 i < WLAN_SUPPORTED_RATES_IE_MAX_LEN); i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 for (j = 0; (j < temp_rate_set.numRates &&
Srinivas Girigowda61771262019-04-01 11:55:19 -07001895 j < WLAN_SUPPORTED_RATES_IE_MAX_LEN); j++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 if ((temp_rate_set2.rate[i] & 0x7F) !=
1897 (temp_rate_set.rate[j] & 0x7F))
1898 continue;
1899
1900 if (sirIsArate(temp_rate_set2.rate[i] & 0x7f) &&
1901 a_rate_index < SIR_NUM_11A_RATES) {
1902 is_arate = 1;
1903 rates->llaRates[a_rate_index++] =
1904 temp_rate_set2.rate[i];
1905 } else if ((b_rate_index < SIR_NUM_11B_RATES) &&
1906 !(sirIsArate(temp_rate_set2.rate[i] & 0x7f))) {
1907 rates->llbRates[b_rate_index++] =
1908 temp_rate_set2.rate[i];
1909 }
1910 break;
1911 }
1912 }
1913
1914 /*
1915 * Now add the Polaris rates only when Proprietary rates are enabled.
1916 * compute the matching MCS rate set, if peer is 11n capable and self
1917 * mode is 11n
1918 */
1919#ifdef FEATURE_WLAN_TDLS
1920 if (sta_ds->mlmStaContext.htCapability)
1921#else
1922 if (IS_DOT11_MODE_HT(session_entry->dot11mode) &&
1923 (sta_ds->mlmStaContext.htCapability))
1924#endif
1925 {
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301926 val_len = SIZE_OF_SUPPORTED_MCS_SET;
1927 if (wlan_mlme_get_cfg_str(
1928 mcs_set,
1929 &mac_ctx->mlme_cfg->rates.supported_mcs_set,
1930 &val_len) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07001931 pe_err("could not retrieve supportedMCSet");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001932 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 }
1934
Arif Hussain74fc5712016-07-20 11:10:01 -07001935 if (session_entry->nss == NSS_1x1_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001936 mcs_set[1] = 0;
1937
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +05301938 for (i = 0; i < val_len; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 sta_ds->supportedRates.supportedMCSSet[i] =
1940 mcs_set[i] & supported_mcs_set[i];
1941
Abhishek Singh3be6fab2020-02-06 12:28:33 +05301942 lim_dump_ht_mcs_mask(mcs_set,
1943 sta_ds->supportedRates.supportedMCSSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 lim_populate_vht_mcs_set(mac_ctx, &sta_ds->supportedRates, vht_caps,
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07001946 session_entry, session_entry->nss, sta_ds);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001947 lim_populate_he_mcs_set(mac_ctx, &sta_ds->supportedRates, he_caps,
1948 session_entry, session_entry->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 /*
1950 * Set the erpEnabled bit if the phy is in G mode and at least
1951 * one A rate is supported
1952 */
1953 if ((phy_mode == WNI_CFG_PHY_MODE_11G) && is_arate)
1954 sta_ds->erpEnabled = eHAL_SET;
1955
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001956 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957}
1958
1959/**
1960 * lim_populate_vht_caps() - populates vht capabilities based on input
1961 * capabilities
1962 * @input_caps: input capabilities based on which we format the vht
1963 * capabilities
1964 *
1965 * function to populate the supported vht capabilities.
1966 *
1967 * Return: vht capabilities derived based on input parameters.
1968 */
1969static uint32_t lim_populate_vht_caps(tDot11fIEVHTCaps input_caps)
1970{
1971 uint32_t vht_caps;
1972
1973 vht_caps = ((input_caps.maxMPDULen << SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
1974 (input_caps.supportedChannelWidthSet <<
1975 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
1976 (input_caps.ldpcCodingCap <<
1977 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
1978 (input_caps.shortGI80MHz <<
1979 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
1980 (input_caps.shortGI160and80plus80MHz <<
1981 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
1982 (input_caps.txSTBC << SIR_MAC_VHT_CAP_TXSTBC) |
1983 (input_caps.rxSTBC << SIR_MAC_VHT_CAP_RXSTBC) |
1984 (input_caps.suBeamFormerCap <<
1985 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
1986 (input_caps.suBeamformeeCap <<
1987 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
1988 (input_caps.csnofBeamformerAntSup <<
1989 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
1990 (input_caps.numSoundingDim <<
1991 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
1992 (input_caps.muBeamformerCap <<
1993 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
1994 (input_caps.muBeamformeeCap <<
1995 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
1996 (input_caps.vhtTXOPPS <<
1997 SIR_MAC_VHT_CAP_TXOPPS) |
1998 (input_caps.htcVHTCap <<
1999 SIR_MAC_VHT_CAP_HTC_CAP) |
2000 (input_caps.maxAMPDULenExp <<
2001 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
2002 (input_caps.vhtLinkAdaptCap <<
2003 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
2004 (input_caps.rxAntPattern <<
2005 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
2006 (input_caps.txAntPattern <<
2007 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07002008 (input_caps.extended_nss_bw_supp <<
2009 SIR_MAC_VHT_CAP_EXTD_NSS_BW));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010
2011 return vht_caps;
2012}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014/**
Arif Hussain53cf5692018-04-05 16:35:54 -07002015 * lim_update_he_stbc_capable() - Update stbc capable flag based on
2016 * HE capability
2017 * @add_sta_params: add sta related parameters
2018 *
2019 * Update stbc cpable flag based on HE capability
2020 *
2021 * Return: None
2022 */
2023#ifdef WLAN_FEATURE_11AX
2024static void lim_update_he_stbc_capable(tpAddStaParams add_sta_params)
2025{
2026 if (add_sta_params &&
2027 add_sta_params->he_capable &&
2028 add_sta_params->stbc_capable)
2029 add_sta_params->stbc_capable =
2030 add_sta_params->he_config.rx_stbc_lt_80mhz;
2031}
2032#else
2033static void lim_update_he_stbc_capable(tpAddStaParams add_sta_params)
2034{}
2035#endif
2036
2037/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 * lim_add_sta()- called to add an STA context at hardware
2039 * @mac_ctx: pointer to global mac structure
2040 * @sta_ds: station node
2041 * @update_entry: set to true for updating the entry
2042 * @session_entry: pe session entry
2043 *
2044 * This function is called to add an STA context at hardware
2045 * whenever a STA is (Re) Associated.
2046 *
Jeff Johnsond9e03512018-06-29 12:04:03 -07002047 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS failure codes
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 */
2049
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002050QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002051lim_add_sta(struct mac_context *mac_ctx,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -08002052 tpDphHashNode sta_ds, uint8_t update_entry, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053{
2054 tpAddStaParams add_sta_params = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002055 struct scheduler_msg msg_q = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002056 QDF_STATUS ret_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057 tSirMacAddr sta_mac, *sta_Addr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 tpSirAssocReq assoc_req;
Kiran Kumar Lokere80d3e1a2017-05-26 15:15:13 -07002059 uint8_t i, nw_type_11b = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 tLimIbssPeerNode *peer_node; /* for IBSS mode */
Naveen Rawat08db88f2017-09-08 15:07:48 -07002061 const uint8_t *p2p_ie = NULL;
Tushnim Bhattacharyya2d693b92018-09-19 13:19:24 -07002062 tDot11fIEVHTCaps vht_caps;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05302063 struct mlme_vht_capabilities_info *vht_cap_info;
2064
2065 vht_cap_info = &mac_ctx->mlme_cfg->vht_caps.vht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302067 sir_copy_mac_addr(sta_mac, session_entry->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002069 pe_debug("sessionid: %d update_entry = %d limsystemrole = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 session_entry->smeSessionId, update_entry,
2071 GET_LIM_SYSTEM_ROLE(session_entry));
2072
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302073 add_sta_params = qdf_mem_malloc(sizeof(tAddStaParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002074 if (!add_sta_params)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002075 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076
Naveen Rawatcb186cf2016-07-11 13:47:19 -07002077 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry) ||
2078 LIM_IS_NDI_ROLE(session_entry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 sta_Addr = &sta_ds->staAddr;
2080#ifdef FEATURE_WLAN_TDLS
2081 /* SystemRole shouldn't be matter if staType is TDLS peer */
2082 else if (STA_ENTRY_TDLS_PEER == sta_ds->staType)
2083 sta_Addr = &sta_ds->staAddr;
2084#endif
2085 else
2086 sta_Addr = &sta_mac;
2087
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002088 pe_debug(QDF_MAC_ADDR_FMT ": Subtype(Assoc/Reassoc): %d",
2089 QDF_MAC_ADDR_REF(*sta_Addr), sta_ds->mlmStaContext.subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302091 qdf_mem_copy((uint8_t *) add_sta_params->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 (uint8_t *) *sta_Addr, sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302093 qdf_mem_copy((uint8_t *) add_sta_params->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 session_entry->bssId, sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302095 qdf_mem_copy(&add_sta_params->capab_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 &sta_ds->mlmStaContext.capabilityInfo,
2097 sizeof(add_sta_params->capab_info));
2098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 /* Copy legacy rates */
Jeff Johnsonecd4f212019-02-01 19:36:34 -08002100 qdf_mem_copy(&add_sta_params->supportedRates,
2101 &sta_ds->supportedRates,
2102 sizeof(sta_ds->supportedRates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103
2104 add_sta_params->assocId = sta_ds->assocId;
2105
2106 add_sta_params->wmmEnabled = sta_ds->qosMode;
2107 add_sta_params->listenInterval = sta_ds->mlmStaContext.listenInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 if (LIM_IS_AP_ROLE(session_entry) &&
2109 (sta_ds->mlmStaContext.subType == LIM_REASSOC)) {
2110 /*
2111 * TBD - need to remove this REASSOC check
2112 * after fixinf rmmod issue
2113 */
2114 add_sta_params->updateSta = sta_ds->mlmStaContext.updateContext;
2115 }
2116 sta_ds->valid = 0;
2117 sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2118
Abhishek Singh6243a002019-09-19 12:55:11 +05302119 pe_debug("Assoc ID: %d wmmEnabled: %d listenInterval: %d",
2120 add_sta_params->assocId, add_sta_params->wmmEnabled,
2121 add_sta_params->listenInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 add_sta_params->staType = sta_ds->staType;
2123
2124 add_sta_params->updateSta = update_entry;
2125
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302126 add_sta_params->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127
Abhishek Singha91d6192017-08-16 17:24:17 +05302128 /* Update VHT/HT Capability */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 if (LIM_IS_AP_ROLE(session_entry) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 LIM_IS_IBSS_ROLE(session_entry)) {
2131 add_sta_params->htCapable = sta_ds->mlmStaContext.htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 add_sta_params->vhtCapable =
2133 sta_ds->mlmStaContext.vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 }
Abhishek Singha91d6192017-08-16 17:24:17 +05302135#ifdef FEATURE_WLAN_TDLS
2136 /* SystemRole shouldn't be matter if staType is TDLS peer */
2137 else if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
2138 add_sta_params->htCapable = sta_ds->mlmStaContext.htCapability;
2139 add_sta_params->vhtCapable =
2140 sta_ds->mlmStaContext.vhtCapability;
2141 }
2142#endif
2143 else {
2144 add_sta_params->htCapable = session_entry->htCapability;
2145 add_sta_params->vhtCapable = session_entry->vhtCapability;
2146 }
2147
Yeshwanth Sriram Guntuka3f262102019-07-16 15:41:08 +05302148 pe_debug("updateSta: %d htcapable: %d vhtCapable: %d sta mac"
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002149 QDF_MAC_ADDR_FMT, add_sta_params->updateSta,
Yeshwanth Sriram Guntuka3f262102019-07-16 15:41:08 +05302150 add_sta_params->htCapable, add_sta_params->vhtCapable,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002151 QDF_MAC_ADDR_REF(add_sta_params->staMac));
Abhishek Singha91d6192017-08-16 17:24:17 +05302152
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002153 /*
Naveen Rawat903acca2017-09-15 17:32:13 -07002154 * If HT client is connected to SAP DUT and self cap is NSS = 2 then
2155 * disable ASYNC DBS scan by sending WMI_VDEV_PARAM_SMPS_INTOLERANT
2156 * to FW, because HT client's can't drop down chain using SMPS frames.
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002157 */
2158 if (!policy_mgr_is_hw_dbs_2x2_capable(mac_ctx->psoc) &&
2159 LIM_IS_AP_ROLE(session_entry) &&
2160 (STA_ENTRY_PEER == sta_ds->staType) &&
2161 !add_sta_params->vhtCapable &&
2162 (session_entry->nss == 2)) {
2163 session_entry->ht_client_cnt++;
Naveen Rawat903acca2017-09-15 17:32:13 -07002164 if (session_entry->ht_client_cnt == 1) {
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002165 pe_debug("setting SMPS intolrent vdev_param");
2166 wma_cli_set_command(session_entry->smeSessionId,
2167 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
2168 1, VDEV_CMD);
2169 }
2170 }
2171
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002172 lim_update_sta_he_capable(mac_ctx, add_sta_params, sta_ds,
2173 session_entry);
2174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 add_sta_params->maxAmpduDensity = sta_ds->htAMpduDensity;
2176 add_sta_params->maxAmpduSize = sta_ds->htMaxRxAMpduFactor;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 add_sta_params->fShortGI20Mhz = sta_ds->htShortGI20Mhz;
2178 add_sta_params->fShortGI40Mhz = sta_ds->htShortGI40Mhz;
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07002179 add_sta_params->ch_width = sta_ds->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180 add_sta_params->mimoPS = sta_ds->htMIMOPSState;
2181
Abhishek Singh6243a002019-09-19 12:55:11 +05302182 pe_debug("maxAmpduDensity: %d maxAmpduDensity: %d",
2183 add_sta_params->maxAmpduDensity, add_sta_params->maxAmpduSize);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184
Abhishek Singh6243a002019-09-19 12:55:11 +05302185 pe_debug("fShortGI20Mhz: %d fShortGI40Mhz: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 add_sta_params->fShortGI20Mhz, add_sta_params->fShortGI40Mhz);
2187
Abhishek Singh6243a002019-09-19 12:55:11 +05302188 pe_debug("txChannelWidth: %d mimoPS: %d", add_sta_params->ch_width,
2189 add_sta_params->mimoPS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190
2191 if (add_sta_params->vhtCapable) {
2192 if (sta_ds->vhtSupportedChannelWidthSet)
2193 add_sta_params->ch_width =
2194 sta_ds->vhtSupportedChannelWidthSet + 1;
2195
2196 add_sta_params->vhtSupportedRxNss = sta_ds->vhtSupportedRxNss;
Kiran Kumar Lokeref1f5e992016-06-20 16:48:50 -07002197 if (LIM_IS_AP_ROLE(session_entry) ||
2198 LIM_IS_P2P_DEVICE_GO(session_entry))
2199 add_sta_params->vhtSupportedRxNss = QDF_MIN(
2200 add_sta_params->vhtSupportedRxNss,
2201 session_entry->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 add_sta_params->vhtTxBFCapable =
2203#ifdef FEATURE_WLAN_TDLS
2204 ((STA_ENTRY_PEER == sta_ds->staType)
2205 || (STA_ENTRY_TDLS_PEER == sta_ds->staType)) ?
Krunal Soni53993f72016-07-08 18:20:03 -07002206 sta_ds->vhtBeamFormerCapable :
2207 session_entry->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208#else
2209 (STA_ENTRY_PEER == sta_ds->staType) ?
Krunal Soni53993f72016-07-08 18:20:03 -07002210 sta_ds->vhtBeamFormerCapable :
2211 session_entry->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212#endif
2213 add_sta_params->enable_su_tx_bformer =
2214 sta_ds->vht_su_bfee_capable;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07002215 add_sta_params->vht_mcs_10_11_supp =
2216 sta_ds->vht_mcs_10_11_supp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 }
2218
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07002219 pe_debug("TxChWidth %d vhtTxBFCap %d, su_bfer %d, vht_mcs11 %d",
2220 add_sta_params->ch_width, add_sta_params->vhtTxBFCapable,
2221 add_sta_params->enable_su_tx_bformer,
2222 add_sta_params->vht_mcs_10_11_supp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223#ifdef FEATURE_WLAN_TDLS
2224 if ((STA_ENTRY_PEER == sta_ds->staType) ||
2225 (STA_ENTRY_TDLS_PEER == sta_ds->staType))
2226#else
2227 if (STA_ENTRY_PEER == sta_ds->staType)
2228#endif
2229 {
2230 /*
2231 * peer STA get the LDPC capability from sta_ds,
2232 * which populated from
2233 * HT/VHT capability
2234 */
2235 if (add_sta_params->vhtTxBFCapable
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05302236 && vht_cap_info->disable_ldpc_with_txbf_ap) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 add_sta_params->htLdpcCapable = 0;
2238 add_sta_params->vhtLdpcCapable = 0;
2239 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08002240 if (session_entry->txLdpcIniFeatureEnabled & 0x1)
2241 add_sta_params->htLdpcCapable =
2242 sta_ds->htLdpcCapable;
2243 else
2244 add_sta_params->htLdpcCapable = 0;
2245
2246 if (session_entry->txLdpcIniFeatureEnabled & 0x2)
2247 add_sta_params->vhtLdpcCapable =
2248 sta_ds->vhtLdpcCapable;
2249 else
2250 add_sta_params->vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 }
2252 } else if (STA_ENTRY_SELF == sta_ds->staType) {
2253 /* For Self STA get the LDPC capability from config.ini */
2254 add_sta_params->htLdpcCapable =
2255 (session_entry->txLdpcIniFeatureEnabled & 0x01);
2256 add_sta_params->vhtLdpcCapable =
2257 ((session_entry->txLdpcIniFeatureEnabled >> 1) & 0x01);
2258 }
2259
2260 /* Update PE session ID */
2261 add_sta_params->sessionId = session_entry->peSessionId;
2262
2263 /* Update SME session ID */
2264 add_sta_params->smesessionId = session_entry->smeSessionId;
2265
2266 add_sta_params->maxTxPower = session_entry->maxTxPower;
2267
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002268 if (session_entry->parsedAssocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 uint16_t aid = sta_ds->assocId;
2270 /* Get a copy of the already parsed Assoc Request */
2271 assoc_req =
2272 (tpSirAssocReq) session_entry->parsedAssocReq[aid];
2273 if (assoc_req && assoc_req->addIEPresent
2274 && assoc_req->addIE.length) {
2275 p2p_ie = limGetP2pIEPtr(mac_ctx,
2276 assoc_req->addIE.addIEdata,
2277 assoc_req->addIE.length);
2278 }
2279
2280 add_sta_params->p2pCapableSta = (p2p_ie != NULL);
2281 if (assoc_req && add_sta_params->htCapable) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302282 qdf_mem_copy(&add_sta_params->ht_caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 ((uint8_t *) &assoc_req->HTCaps) + 1,
2284 sizeof(add_sta_params->ht_caps));
2285 }
2286
Tushnim Bhattacharyya2d693b92018-09-19 13:19:24 -07002287 if (assoc_req && add_sta_params->vhtCapable) {
2288 if (assoc_req->vendor_vht_ie.VHTCaps.present)
2289 vht_caps = assoc_req->vendor_vht_ie.VHTCaps;
2290 else
2291 vht_caps = assoc_req->VHTCaps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 add_sta_params->vht_caps =
Tushnim Bhattacharyya2d693b92018-09-19 13:19:24 -07002293 lim_populate_vht_caps(vht_caps);
2294 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002295
Amruta Kulkarni4edc97d2019-12-18 16:13:07 -08002296 lim_add_he_cap(mac_ctx, session_entry,
2297 add_sta_params, assoc_req);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 } else if (LIM_IS_IBSS_ROLE(session_entry)) {
2300
2301 /*
2302 * in IBSS mode, use peer node as the source of ht_caps
2303 * and vht_caps
2304 */
2305 peer_node = lim_ibss_peer_find(mac_ctx, *sta_Addr);
2306 if (!peer_node) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002307 pe_err("Can't find IBSS peer node for ADD_STA");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002308 return QDF_STATUS_E_NOENT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 }
2310
2311 if (peer_node->atimIePresent) {
2312 add_sta_params->atimIePresent =
2313 peer_node->atimIePresent;
2314 add_sta_params->peerAtimWindowLength =
2315 peer_node->peerAtimWindowLength;
2316 }
2317
2318 add_sta_params->ht_caps =
2319 (peer_node->htSupportedChannelWidthSet <<
2320 SIR_MAC_HT_CAP_CHWIDTH40_S) |
2321 (peer_node->htGreenfield <<
2322 SIR_MAC_HT_CAP_GREENFIELD_S) |
2323 (peer_node->htShortGI20Mhz <<
2324 SIR_MAC_HT_CAP_SHORTGI20MHZ_S) |
2325 (peer_node->htShortGI40Mhz <<
2326 SIR_MAC_HT_CAP_SHORTGI40MHZ_S) |
2327 (SIR_MAC_TXSTBC <<
2328 SIR_MAC_HT_CAP_TXSTBC_S) |
2329 (SIR_MAC_RXSTBC <<
2330 SIR_MAC_HT_CAP_RXSTBC_S) |
2331 (peer_node->htMaxAmsduLength <<
2332 SIR_MAC_HT_CAP_MAXAMSDUSIZE_S) |
2333 (peer_node->htDsssCckRate40MHzSupport <<
2334 SIR_MAC_HT_CAP_DSSSCCK40_S);
2335
2336 add_sta_params->vht_caps =
2337 lim_populate_vht_caps(peer_node->VHTCaps);
2338 }
2339#ifdef FEATURE_WLAN_TDLS
2340 if (STA_ENTRY_TDLS_PEER == sta_ds->staType) {
2341 add_sta_params->ht_caps = sta_ds->ht_caps;
2342 add_sta_params->vht_caps = sta_ds->vht_caps;
hangtiand152e8d2019-02-23 11:28:23 +08002343 if (add_sta_params->vhtCapable) {
2344 add_sta_params->maxAmpduSize =
2345 SIR_MAC_GET_VHT_MAX_AMPDU_EXPO(
2346 sta_ds->vht_caps);
2347 }
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002348 pe_debug("Sta type is TDLS_PEER, ht_caps: 0x%x, vht_caps: 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349 add_sta_params->ht_caps,
2350 add_sta_params->vht_caps);
2351 }
2352#endif
2353
2354#ifdef FEATURE_WLAN_TDLS
2355 if (sta_ds->wmeEnabled &&
2356 (LIM_IS_AP_ROLE(session_entry) ||
2357 (STA_ENTRY_TDLS_PEER == sta_ds->staType)))
2358#else
2359 if (sta_ds->wmeEnabled && LIM_IS_AP_ROLE(session_entry))
2360#endif
2361 {
2362 add_sta_params->uAPSD = 0;
2363 /*
2364 * update UAPSD and send it to LIM to add STA
2365 * bitmap MSB <- LSB MSB 4 bits are for
2366 * trigger enabled AC setting and LSB 4 bits
2367 * are for delivery enabled AC setting
2368 * 7 6 5 4 3 2 1 0
2369 * BE BK VI VO BE BK VI VO
2370 */
2371 add_sta_params->uAPSD |=
2372 sta_ds->qos.capability.qosInfo.acvo_uapsd;
2373 add_sta_params->uAPSD |=
2374 (sta_ds->qos.capability.qosInfo.acvi_uapsd << 1);
2375 add_sta_params->uAPSD |=
2376 (sta_ds->qos.capability.qosInfo.acbk_uapsd << 2);
2377 add_sta_params->uAPSD |=
2378 (sta_ds->qos.capability.qosInfo.acbe_uapsd << 3);
2379 /*
2380 * making delivery enabled and
2381 * trigger enabled setting the same.
2382 */
2383 add_sta_params->uAPSD |= add_sta_params->uAPSD << 4;
2384
2385 add_sta_params->maxSPLen =
2386 sta_ds->qos.capability.qosInfo.maxSpLen;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002387 pe_debug("uAPSD = 0x%x, maxSpLen = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 add_sta_params->uAPSD, add_sta_params->maxSPLen);
2389 }
2390#ifdef WLAN_FEATURE_11W
2391 add_sta_params->rmfEnabled = sta_ds->rmfEnabled;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002392 pe_debug("PMF enabled %d", add_sta_params->rmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393#endif
2394
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002395 pe_debug("htLdpcCapable: %d vhtLdpcCapable: %d "
2396 "p2pCapableSta: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 add_sta_params->htLdpcCapable, add_sta_params->vhtLdpcCapable,
2398 add_sta_params->p2pCapableSta);
2399
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08002400 if (!add_sta_params->htLdpcCapable)
2401 add_sta_params->ht_caps &= ~(1 << SIR_MAC_HT_CAP_ADVCODING_S);
2402 if (!add_sta_params->vhtLdpcCapable)
2403 add_sta_params->vht_caps &=
2404 ~(1 << SIR_MAC_VHT_CAP_LDPC_CODING_CAP);
2405
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 /*
2407 * we need to defer the message until we get the
2408 * response back from HAL.
2409 */
Abhishek Singh6243a002019-09-19 12:55:11 +05302410 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411
yeshwanth sriram guntuka47f26e62017-03-07 12:43:02 +05302412 add_sta_params->nwType = session_entry->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413
Kiran Kumar Lokere80d3e1a2017-05-26 15:15:13 -07002414 if (!(add_sta_params->htCapable || add_sta_params->vhtCapable)) {
2415 nw_type_11b = 1;
2416 for (i = 0; i < SIR_NUM_11A_RATES; i++) {
2417 if (sirIsArate(sta_ds->supportedRates.llaRates[i] &
2418 0x7F)) {
2419 nw_type_11b = 0;
2420 break;
2421 }
2422 }
2423 if (nw_type_11b)
2424 add_sta_params->nwType = eSIR_11B_NW_TYPE;
2425 }
2426
Jeff Johnsonbe119e62019-02-02 12:30:26 -08002427 if (add_sta_params->htCapable && session_entry->ht_config.ht_tx_stbc) {
Arif Hussain53cf5692018-04-05 16:35:54 -07002428 struct sDot11fIEHTCaps *ht_caps = (struct sDot11fIEHTCaps *)
2429 &add_sta_params->ht_caps;
2430 if (ht_caps->rxSTBC)
2431 add_sta_params->stbc_capable = 1;
2432 else
2433 add_sta_params->stbc_capable = 0;
2434 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435
Arif Hussain53cf5692018-04-05 16:35:54 -07002436 if (add_sta_params->vhtCapable && add_sta_params->stbc_capable) {
2437 struct sDot11fIEVHTCaps *vht_caps = (struct sDot11fIEVHTCaps *)
2438 &add_sta_params->vht_caps;
2439 if (vht_caps->rxSTBC)
2440 add_sta_params->stbc_capable = 1;
2441 else
2442 add_sta_params->stbc_capable = 0;
2443 }
2444
Abhishek Amburea7f1c222019-11-27 19:54:26 +05302445 if (session_entry->opmode == QDF_SAP_MODE ||
2446 session_entry->opmode == QDF_P2P_GO_MODE) {
2447 if (session_entry->parsedAssocReq) {
2448 uint16_t aid = sta_ds->assocId;
2449 /* Get a copy of the already parsed Assoc Request */
2450 assoc_req =
2451 (tpSirAssocReq) session_entry->parsedAssocReq[aid];
2452
android-t108a9ce02022-11-01 09:57:42 +08002453 if (assoc_req) {
2454 add_sta_params->wpa_rsn = assoc_req->rsnPresent;
2455 add_sta_params->wpa_rsn |=
2456 (assoc_req->wpaPresent << 1);
2457 }
Abhishek Amburea7f1c222019-11-27 19:54:26 +05302458 }
2459 }
2460
Arif Hussain53cf5692018-04-05 16:35:54 -07002461 lim_update_he_stbc_capable(add_sta_params);
2462
2463 msg_q.type = WMA_ADD_STA_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 msg_q.reserved = 0;
2465 msg_q.bodyptr = add_sta_params;
2466 msg_q.bodyval = 0;
2467
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002468 pe_debug("Sending WMA_ADD_STA_REQ for assocId %d", sta_ds->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId,
2470 msg_q.type));
2471
2472 ret_code = wma_post_ctrl_msg(mac_ctx, &msg_q);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002473 if (QDF_STATUS_SUCCESS != ret_code) {
Abhishek Singh6243a002019-09-19 12:55:11 +05302474 SET_LIM_PROCESS_DEFD_MESGS(mac_ctx, true);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002475 pe_err("ADD_STA_REQ for aId %d failed (reason %X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476 sta_ds->assocId, ret_code);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302477 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 }
2479
2480 return ret_code;
2481}
2482
2483/**
2484 * lim_del_sta()
2485 *
2486 ***FUNCTION:
2487 * This function is called to delete an STA context at hardware
2488 * whenever a STA is disassociated
2489 *
2490 ***LOGIC:
2491 *
2492 ***ASSUMPTIONS:
2493 * NA
2494 *
2495 ***NOTE:
2496 * NA
2497 *
Jeff Johnsonab322b92018-11-21 23:10:49 -08002498 * @param mac - Pointer to Global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002499 * @param sta - Pointer to the STA datastructure created by
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 * LIM and maintained by DPH
2501 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2502 * or not (false)
2503 * @return retCode - Indicates success or failure return code
2504 */
2505
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002506QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002507lim_del_sta(struct mac_context *mac,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002508 tpDphHashNode sta, bool fRespReqd, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509{
2510 tpDeleteStaParams pDelStaParams = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002511 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002512 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302514 pDelStaParams = qdf_mem_malloc(sizeof(tDeleteStaParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002515 if (!pDelStaParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002516 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002518 /*
2519 * 2G-AS platform: SAP associates with HT (11n)clients as 2x1 in 2G and
2520 * 2X2 in 5G
2521 * Non-2G-AS platform: SAP associates with HT (11n) clients as 2X2 in 2G
2522 * and 5G; and enable async dbs scan when all HT clients are gone
2523 * 5G-AS: Don't care
2524 */
Jeff Johnsonab322b92018-11-21 23:10:49 -08002525 if (!policy_mgr_is_hw_dbs_2x2_capable(mac->psoc) &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002526 LIM_IS_AP_ROLE(pe_session) &&
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002527 (sta->staType == STA_ENTRY_PEER) &&
2528 !sta->mlmStaContext.vhtCapability &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002529 (pe_session->nss == 2)) {
2530 pe_session->ht_client_cnt--;
2531 if (pe_session->ht_client_cnt == 0) {
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002532 pe_debug("clearing SMPS intolrent vdev_param");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002533 wma_cli_set_command(pe_session->smeSessionId,
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07002534 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
2535 0, VDEV_CMD);
2536 }
2537 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002539 pDelStaParams->assocId = sta->assocId;
2540 sta->valid = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541
2542 if (!fRespReqd)
2543 pDelStaParams->respReqd = 0;
2544 else {
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002545 if (!(IS_TDLS_PEER(sta->staType))) {
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302546 /* when lim_del_sta is called from processSmeAssocCnf
2547 * then mlmState is already set properly. */
2548 if (eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE !=
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002549 GET_LIM_STA_CONTEXT_MLM_STATE(sta)) {
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302550 MTRACE(mac_trace
Jeff Johnsonab322b92018-11-21 23:10:49 -08002551 (mac, TRACE_CODE_MLM_STATE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002552 pe_session->peSessionId,
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302553 eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002554 SET_LIM_STA_CONTEXT_MLM_STATE(sta,
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302555 eLIM_MLM_WT_DEL_STA_RSP_STATE);
2556 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002557 if (LIM_IS_STA_ROLE(pe_session)) {
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302558 MTRACE(mac_trace
Jeff Johnsonab322b92018-11-21 23:10:49 -08002559 (mac, TRACE_CODE_MLM_STATE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002560 pe_session->peSessionId,
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302561 eLIM_MLM_WT_DEL_STA_RSP_STATE));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002563 pe_session->limMlmState =
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302564 eLIM_MLM_WT_DEL_STA_RSP_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302566 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 }
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302568
2569 /* we need to defer the message until we get the
2570 * response back from HAL. */
Jeff Johnsonab322b92018-11-21 23:10:49 -08002571 SET_LIM_PROCESS_DEFD_MESGS(mac, false);
Ganesh Kondabattini520a83d2017-03-14 20:02:34 +05302572
2573 pDelStaParams->respReqd = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 }
2575
2576 /* Update PE session ID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002577 pDelStaParams->sessionId = pe_session->peSessionId;
2578 pDelStaParams->smesessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002580 pDelStaParams->staType = sta->staType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302581 qdf_mem_copy((uint8_t *) pDelStaParams->staMac,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002582 (uint8_t *) sta->staAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302584 pDelStaParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 msgQ.type = WMA_DELETE_STA_REQ;
2586 msgQ.reserved = 0;
2587 msgQ.bodyptr = pDelStaParams;
2588 msgQ.bodyval = 0;
2589
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002590 pe_debug("Sessionid %d :Sending SIR_HAL_DELETE_STA_REQ "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002591 "for mac_addr "QDF_MAC_ADDR_FMT" and AssocID: %d MAC : "
2592 QDF_MAC_ADDR_FMT, pDelStaParams->sessionId,
2593 QDF_MAC_ADDR_REF(pDelStaParams->staMac),
2594 pDelStaParams->assocId,
2595 QDF_MAC_ADDR_REF(sta->staAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002597 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, msgQ.type));
Jeff Johnsonab322b92018-11-21 23:10:49 -08002598 retCode = wma_post_ctrl_msg(mac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002599 if (QDF_STATUS_SUCCESS != retCode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 if (fRespReqd)
Jeff Johnsonab322b92018-11-21 23:10:49 -08002601 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002602 pe_err("Posting DELETE_STA_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302604 qdf_mem_free(pDelStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 }
2606
2607 return retCode;
2608}
2609
hquf2c30992019-05-14 20:17:28 +08002610/**
2611 * lim_set_mbssid_info() - Save mbssid info
2612 * @pe_session: pe session entry
2613 *
2614 * Return: None
2615 */
hquf2c30992019-05-14 20:17:28 +08002616static void lim_set_mbssid_info(struct pe_session *pe_session)
2617{
2618 struct scan_mbssid_info *mbssid_info;
2619
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302620 mbssid_info = &pe_session->lim_join_req->bssDescription.mbssid_info;
hquf2c30992019-05-14 20:17:28 +08002621 mlme_set_mbssid_info(pe_session->vdev, mbssid_info);
2622}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623
2624/**
2625 * lim_add_sta_self()
2626 *
2627 ***FUNCTION:
2628 * This function is called to add an STA context at hardware
2629 * whenever a STA is (Re) Associated.
2630 *
2631 ***LOGIC:
2632 *
2633 ***ASSUMPTIONS:
2634 * NA
2635 *
2636 ***NOTE:
2637 * NA
2638 *
Jeff Johnsonab322b92018-11-21 23:10:49 -08002639 * @param mac - Pointer to Global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002640 * @param sta - Pointer to the STA datastructure created by
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 * LIM and maintained by DPH
2642 * @return retCode - Indicates success or failure return code
2643 */
2644
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002645QDF_STATUS
Yeshwanth Sriram Guntuka3f262102019-07-16 15:41:08 +05302646lim_add_sta_self(struct mac_context *mac, uint8_t updateSta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002647 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648{
2649 tpAddStaParams pAddStaParams = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002650 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002651 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 tSirMacAddr staMac;
Pragaspathi Thilagaraj3cf0f652018-10-29 16:40:35 +05302653 uint32_t listenInterval = MLME_CFG_LISTEN_INTERVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2655 * that cfg carries the systemwide capability that device under
2656 * consideration can support. This capability gets plumbed into the cfg
2657 * cache at system initialization time via the .dat and .ini file override
2658 * mechanisms and will not change. If it does change, it is the
2659 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2660 * command.*/
Wu Gaoccd9ca22019-01-17 14:16:43 +08002661 uint32_t selfStaDot11Mode = 0;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002662
gaurank kathpalia1be77fa2019-01-04 13:32:09 +05302663 selfStaDot11Mode = mac->mlme_cfg->dot11_mode.dot11_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302665 sir_copy_mac_addr(staMac, pe_session->self_mac_addr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302666 pAddStaParams = qdf_mem_malloc(sizeof(tAddStaParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002667 if (!pAddStaParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002668 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
2670 /* / Add STA context at MAC HW (BMU, RHP & TFP) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302671 qdf_mem_copy((uint8_t *) pAddStaParams->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 (uint8_t *) staMac, sizeof(tSirMacAddr));
2673
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302674 qdf_mem_copy((uint8_t *) pAddStaParams->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002675 pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002677 pAddStaParams->assocId = pe_session->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 pAddStaParams->staType = STA_ENTRY_SELF;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302679 pAddStaParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680
2681 /* Update PE session ID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002682 pAddStaParams->sessionId = pe_session->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683
2684 /* Update SME session ID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002685 pAddStaParams->smesessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002687 pAddStaParams->maxTxPower = pe_session->maxTxPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 pAddStaParams->updateSta = updateSta;
2690
hquf2c30992019-05-14 20:17:28 +08002691 lim_set_mbssid_info(pe_session);
2692
Jeff Johnsonff432cd2018-12-14 22:57:41 -08002693 lim_populate_own_rate_set(mac, &pAddStaParams->supportedRates,
2694 NULL, false,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002695 pe_session, NULL, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 if (IS_DOT11_MODE_HT(selfStaDot11Mode)) {
2697 pAddStaParams->htCapable = true;
Abhishek Singh6243a002019-09-19 12:55:11 +05302698
Jeff Johnsonff432cd2018-12-14 22:57:41 -08002699 pAddStaParams->ch_width =
2700 mac->roam.configParam.channelBondingMode5GHz;
2701 pAddStaParams->mimoPS =
2702 lim_get_ht_capability(mac, eHT_MIMO_POWER_SAVE,
2703 pe_session);
Jeff Johnsonff432cd2018-12-14 22:57:41 -08002704 pAddStaParams->maxAmpduDensity =
2705 lim_get_ht_capability(mac, eHT_MPDU_DENSITY,
2706 pe_session);
2707 pAddStaParams->maxAmpduSize =
2708 lim_get_ht_capability(mac, eHT_MAX_RX_AMPDU_FACTOR,
2709 pe_session);
Jeff Johnsonbe119e62019-02-02 12:30:26 -08002710 pAddStaParams->fShortGI20Mhz = pe_session->ht_config.ht_sgi20;
2711 pAddStaParams->fShortGI40Mhz = pe_session->ht_config.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 }
Abhinav Kumar2ae25242020-05-11 22:46:11 +05302713 pAddStaParams->vhtCapable = pe_session->vhtCapability;
gaurank kathpalia385977d2020-02-06 11:41:10 +05302714 if (pAddStaParams->vhtCapable)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 pAddStaParams->ch_width =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002716 pe_session->ch_width;
gaurank kathpalia385977d2020-02-06 11:41:10 +05302717
Krunal Soni53993f72016-07-08 18:20:03 -07002718 pAddStaParams->vhtTxBFCapable =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002719 pe_session->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 pAddStaParams->enable_su_tx_bformer =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002721 pe_session->vht_config.su_beam_former;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722
2723 /* In 11ac mode, the hardware is capable of supporting 128K AMPDU size */
Abhinav Kumar2ae25242020-05-11 22:46:11 +05302724 if (pe_session->vhtCapability)
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05302725 pAddStaParams->maxAmpduSize =
Jeff Johnsonab322b92018-11-21 23:10:49 -08002726 mac->mlme_cfg->vht_caps.vht_cap_info.ampdu_len_exponent;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05302727
Krunal Soni53993f72016-07-08 18:20:03 -07002728 pAddStaParams->vhtTxMUBformeeCapable =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002729 pe_session->vht_config.mu_beam_formee;
2730 pAddStaParams->enableVhtpAid = pe_session->enableVhtpAid;
2731 pAddStaParams->enableAmpduPs = pe_session->enableAmpduPs;
2732 pAddStaParams->enableHtSmps = (pe_session->enableHtSmps &&
2733 (!pe_session->supported_nss_1x1));
2734 pAddStaParams->htSmpsconfig = pe_session->htSmpsvalue;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002735 pAddStaParams->send_smps_action =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002736 pe_session->send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737
2738 /* For Self STA get the LDPC capability from session i.e config.ini */
2739 pAddStaParams->htLdpcCapable =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002740 (pe_session->txLdpcIniFeatureEnabled & 0x01);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 pAddStaParams->vhtLdpcCapable =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002742 ((pe_session->txLdpcIniFeatureEnabled >> 1) & 0x01);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743
Jeff Johnsonab322b92018-11-21 23:10:49 -08002744 listenInterval = mac->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 pAddStaParams->listenInterval = (uint16_t) listenInterval;
2746
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302747 if (QDF_P2P_CLIENT_MODE == pe_session->opmode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 pAddStaParams->p2pCapableSta = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002750 if (pe_session->isNonRoamReassoc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 pAddStaParams->nonRoamReassoc = 1;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002752 pe_session->isNonRoamReassoc = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002753 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002755 if (IS_DOT11_MODE_HE(selfStaDot11Mode))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002756 lim_add_self_he_cap(pAddStaParams, pe_session);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002757
bings11172832019-05-23 16:41:25 +08002758 if (lim_is_fils_connection(pe_session))
2759 pAddStaParams->no_ptk_4_way = true;
2760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 msgQ.type = WMA_ADD_STA_REQ;
2762 msgQ.reserved = 0;
2763 msgQ.bodyptr = pAddStaParams;
2764 msgQ.bodyval = 0;
2765
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002766 pe_debug(QDF_MAC_ADDR_FMT ": vdev %d Sending WMA_ADD_STA_REQ.LI %d",
2767 QDF_MAC_ADDR_REF(pAddStaParams->staMac),
gaurank kathpalia385977d2020-02-06 11:41:10 +05302768 pe_session->vdev_id, pAddStaParams->listenInterval);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002769 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770
Jeff Johnsonab322b92018-11-21 23:10:49 -08002771 retCode = wma_post_ctrl_msg(mac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002772 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002773 pe_err("Posting WMA_ADD_STA_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302775 qdf_mem_free(pAddStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 }
2777 return retCode;
2778}
2779
2780/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 * lim_handle_cnf_wait_timeout()
2782 *
2783 ***FUNCTION:
2784 * This function is called by limProcessMessageQueue to handle
2785 * various confirmation failure cases.
2786 *
2787 ***LOGIC:
2788 *
2789 ***ASSUMPTIONS:
2790 *
2791 ***NOTE:
2792 *
Jeff Johnsonab322b92018-11-21 23:10:49 -08002793 * @param mac - Pointer to Global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002794 * @param sta - Pointer to a sta descriptor
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 * @return None
2796 */
2797
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002798void lim_handle_cnf_wait_timeout(struct mac_context *mac, uint16_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799{
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002800 tpDphHashNode sta;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002801 struct pe_session *pe_session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002803 pe_session = pe_find_session_by_session_id(mac,
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05302804 mac->lim.lim_timers.gpLimCnfWaitTimer[staId].sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002805 if (!pe_session) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002806 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002807 return;
2808 }
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002809 sta = dph_get_hash_entry(mac, staId, &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002811 if (!sta) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002812 pe_err("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813 return;
2814 }
2815
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002816 switch (sta->mlmStaContext.mlmState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002818 pe_debug("Did not receive Assoc Cnf in eLIM_MLM_WT_ASSOC_CNF_STATE sta Assoc id %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002819 sta->assocId);
2820 lim_print_mac_addr(mac, sta->staAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002822 if (LIM_IS_AP_ROLE(pe_session)) {
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002823 lim_reject_association(mac, sta->staAddr,
2824 sta->mlmStaContext.subType,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 true,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002826 sta->mlmStaContext.authType,
2827 sta->assocId, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002829 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 }
2831 break;
2832
2833 default:
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002834 pe_warn("Received CNF_WAIT_TIMEOUT in state %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002835 sta->mlmStaContext.mlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 }
2837}
2838
2839/**
2840 * lim_delete_dph_hash_entry()- function to delete dph hash entry
2841 * @mac_ctx: pointer to global mac structure
2842 * @sta_addr: peer station address
2843 * @sta_id: id assigned to peer station
2844 * @session_entry: pe session entry
2845 *
2846 * This function is called whenever we need to delete
2847 * the dph hash entry
2848 *
2849 * Return: none
2850 */
2851
2852void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002853lim_delete_dph_hash_entry(struct mac_context *mac_ctx, tSirMacAddr sta_addr,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -08002854 uint16_t sta_id, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855{
2856 uint16_t aid;
2857 tpDphHashNode sta_ds;
2858 tUpdateBeaconParams beacon_params;
2859
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302860 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 beacon_params.paramChangeBitmap = 0;
2862 lim_deactivate_and_change_per_sta_id_timer(mac_ctx, eLIM_CNF_WAIT_TIMER,
2863 sta_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002864 if (!session_entry) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002865 pe_err("NULL session_entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866 return;
2867 }
2868
Abhishek Singhc70afa32019-09-19 15:17:21 +05302869 beacon_params.bss_idx = session_entry->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 sta_ds = dph_lookup_hash_entry(mac_ctx, sta_addr, &aid,
2871 &session_entry->dph.dphHashTable);
2872
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002873 if (!sta_ds) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002874 pe_err("sta_ds is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 return;
2876 }
2877
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002878 pe_debug("Deleting DPH Hash entry sta mac " QDF_MAC_ADDR_FMT,
2879 QDF_MAC_ADDR_REF(sta_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 /*
2881 * update the station count and perform associated actions
2882 * do this before deleting the dph hash entry
2883 */
2884 lim_util_count_sta_del(mac_ctx, sta_ds, session_entry);
2885
2886 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry)) {
2887 if (LIM_IS_AP_ROLE(session_entry)) {
2888 if (session_entry->gLimProtectionControl !=
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05302889 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 lim_decide_ap_protection_on_delete(mac_ctx,
2891 sta_ds, &beacon_params, session_entry);
2892 }
2893
gaolez7bb1e742017-03-21 16:37:38 +08002894 if (sta_ds->non_ecsa_capable) {
2895 if (session_entry->lim_non_ecsa_cap_num == 0) {
2896 pe_debug("NonECSA sta 0, id %d is ecsa",
2897 sta_id);
2898 } else {
2899 session_entry->lim_non_ecsa_cap_num--;
2900 pe_debug("reducing the non ECSA num to %d",
2901 session_entry->lim_non_ecsa_cap_num);
2902 }
2903 }
2904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 if (LIM_IS_IBSS_ROLE(session_entry))
2906 lim_ibss_decide_protection_on_delete(mac_ctx, sta_ds,
2907 &beacon_params, session_entry);
2908
2909 lim_decide_short_preamble(mac_ctx, sta_ds, &beacon_params,
2910 session_entry);
2911 lim_decide_short_slot(mac_ctx, sta_ds, &beacon_params,
2912 session_entry);
2913
2914 /* Send message to HAL about beacon parameter change. */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002915 pe_debug("param bitmap: %d", beacon_params.paramChangeBitmap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 if (beacon_params.paramChangeBitmap &&
2917 (false ==
2918 mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
2919 sch_set_fixed_beacon_fields(mac_ctx, session_entry);
2920 lim_send_beacon_params(mac_ctx, &beacon_params,
2921 session_entry);
2922 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002923
2924 lim_obss_send_detection_cfg(mac_ctx, session_entry, false);
2925
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926#ifdef WLAN_FEATURE_11W
Krunal Sonia59e8a42017-11-19 09:00:56 -08002927 if (sta_ds->rmfEnabled) {
Yeshwanth Sriram Guntukae6b54242019-07-16 14:54:16 +05302928 pe_debug("delete pmf timer assoc-id:%d sta mac "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07002929 QDF_MAC_ADDR_FMT, sta_ds->assocId,
2930 QDF_MAC_ADDR_REF(sta_ds->staAddr));
Krunal Sonia59e8a42017-11-19 09:00:56 -08002931 tx_timer_delete(&sta_ds->pmfSaQueryTimer);
2932 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933#endif
2934 }
2935
2936 if (dph_delete_hash_entry(mac_ctx, sta_addr, sta_id,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002937 &session_entry->dph.dphHashTable) != QDF_STATUS_SUCCESS)
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002938 pe_err("error deleting hash entry");
Liangwei Dong05276172019-12-27 10:31:46 +08002939 lim_ap_check_6g_compatible_peer(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940}
2941
2942/**
2943 * lim_check_and_announce_join_success()- function to check if the received
2944 * Beacon/Probe Response is from the BSS that we're attempting to join.
2945 * @mac: pointer to global mac structure
2946 * @beacon_probe_rsp: pointer to reveived beacon/probe response frame
2947 * @header: pointer to received management frame header
2948 * @session_entry: pe session entry
2949 *
2950 * This function is called upon receiving Beacon/Probe Response
2951 * frame in WT_JOIN_BEACON_STATE to check if the received
2952 * Beacon/Probe Response is from the BSS that we're attempting
2953 * to join.
2954 * If the Beacon/Probe Response is indeed from the BSS we're
2955 * attempting to join, join success is sent to SME.
2956 *
2957 * Return: none
2958 */
2959
2960void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002961lim_check_and_announce_join_success(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 tSirProbeRespBeacon *beacon_probe_rsp, tpSirMacMgmtHdr header,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -08002963 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964{
2965 tSirMacSSid current_ssid;
2966 tLimMlmJoinCnf mlm_join_cnf;
Arif Hussain43e09712018-09-18 19:31:57 -07002967 uint32_t val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 uint32_t *noa_duration_from_beacon = NULL;
2969 uint32_t *noa2_duration_from_beacon = NULL;
2970 uint32_t noa;
2971 uint32_t total_num_noa_desc = 0;
2972
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302973 qdf_mem_copy(current_ssid.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 session_entry->ssId.ssId, session_entry->ssId.length);
2975
2976 current_ssid.length = (uint8_t) session_entry->ssId.length;
2977
2978 /*
2979 * Check for SSID only in probe response. Beacons may not carry
2980 * SSID information in hidden SSID case
2981 */
2982 if (((SIR_MAC_MGMT_FRAME == header->fc.type) &&
2983 (SIR_MAC_MGMT_PROBE_RSP == header->fc.subType)) &&
2984 current_ssid.length &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302985 (qdf_mem_cmp((uint8_t *) &beacon_probe_rsp->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 (uint8_t *) &current_ssid,
2987 (uint8_t) (1 + current_ssid.length)))) {
2988 /*
2989 * Received SSID does not match with the one we've.
2990 * Ignore received Beacon frame
2991 */
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07002992 pe_debug("SSID received in Beacon does not match");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993#ifdef WLAN_DEBUG
2994 mac_ctx->lim.gLimBcnSSIDMismatchCnt++;
2995#endif
2996 return;
2997 }
2998
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07002999 if (!LIM_IS_STA_ROLE(session_entry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000 return;
3001
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07003002 pe_debug("Received Beacon/PR with BSSID:"QDF_MAC_ADDR_FMT" pe session %d vdev %d",
3003 QDF_MAC_ADDR_REF(session_entry->bssId),
3004 session_entry->peSessionId,
gaurank kathpalia385977d2020-02-06 11:41:10 +05303005 session_entry->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006
3007 /* Deactivate Join Failure timer */
3008 lim_deactivate_and_change_timer(mac_ctx, eLIM_JOIN_FAIL_TIMER);
3009 /* Deactivate Periodic Join timer */
3010 lim_deactivate_and_change_timer(mac_ctx,
3011 eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
3012
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303013 if (QDF_P2P_CLIENT_MODE == session_entry->opmode &&
3014 beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015
3016 noa_duration_from_beacon = (uint32_t *)
3017 (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3018
3019 if (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3020 total_num_noa_desc =
3021 beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.
3022 num_NoADesc / SIZE_OF_NOA_DESCRIPTOR;
3023
3024 noa = *noa_duration_from_beacon;
3025
3026 if (total_num_noa_desc > 1) {
3027 noa2_duration_from_beacon = (uint32_t *)
3028 (beacon_probe_rsp->P2PProbeRes.NoticeOfAbsence.NoADesc +
3029 SIZE_OF_NOA_DESCRIPTOR + 1);
3030 noa += *noa2_duration_from_beacon;
3031 }
3032
3033 /*
3034 * If MAX Noa exceeds 3 secs we will consider only 3 secs to
Jeff Johnson47d75242018-05-12 15:58:53 -07003035 * avoid arbitrary values in noa duration field
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 */
3037 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ?
3038 MAX_NOA_PERIOD_IN_MICROSECS : noa;
3039 noa = noa / 1000; /* Convert to ms */
3040
Arif Hussain43e09712018-09-18 19:31:57 -07003041 session_entry->defaultAuthFailureTimeout =
3042 mac_ctx->mlme_cfg->timeouts.auth_failure_timeout;
3043 val = mac_ctx->mlme_cfg->timeouts.auth_failure_timeout + noa;
3044 if (cfg_in_range(CFG_AUTH_FAILURE_TIMEOUT, val))
3045 mac_ctx->mlme_cfg->timeouts.auth_failure_timeout = val;
3046 else
3047 mac_ctx->mlme_cfg->timeouts.auth_failure_timeout =
3048 cfg_default(CFG_AUTH_FAILURE_TIMEOUT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 } else {
3050 session_entry->defaultAuthFailureTimeout = 0;
3051 }
3052
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303053
3054 /*
3055 * Check if MBO Association disallowed subattr is present and post
3056 * failure status to LIM if present
3057 */
3058 if (!session_entry->ignore_assoc_disallowed &&
3059 beacon_probe_rsp->assoc_disallowed) {
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07003060 pe_err("Connection fails due to assoc disallowed reason(%d):"QDF_MAC_ADDR_FMT" PESessionID %d",
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303061 beacon_probe_rsp->assoc_disallowed_reason,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07003062 QDF_MAC_ADDR_REF(session_entry->bssId),
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303063 session_entry->peSessionId);
3064 mlm_join_cnf.resultCode = eSIR_SME_ASSOC_REFUSED;
3065 mlm_join_cnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3066 session_entry->limMlmState = eLIM_MLM_IDLE_STATE;
3067 mlm_join_cnf.sessionId = session_entry->peSessionId;
3068 if (session_entry->pLimMlmJoinReq) {
3069 qdf_mem_free(session_entry->pLimMlmJoinReq);
3070 session_entry->pLimMlmJoinReq = NULL;
3071 }
3072 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
3073 (uint32_t *) &mlm_join_cnf);
3074 return;
3075 }
3076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 /* Update Beacon Interval at CFG database */
3078
3079 if (beacon_probe_rsp->HTCaps.present)
3080 lim_update_sta_run_time_ht_capability(mac_ctx,
3081 &beacon_probe_rsp->HTCaps);
3082 if (beacon_probe_rsp->HTInfo.present)
3083 lim_update_sta_run_time_ht_info(mac_ctx,
3084 &beacon_probe_rsp->HTInfo, session_entry);
3085 session_entry->limMlmState = eLIM_MLM_JOINED_STATE;
3086 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
3087 session_entry->peSessionId, eLIM_MLM_JOINED_STATE));
3088
3089 /*
3090 * update the capability info based on recently received beacon/probe
3091 * response frame
3092 */
3093 session_entry->limCurrentBssCaps =
3094 lim_get_u16((uint8_t *)&beacon_probe_rsp->capabilityInfo);
3095
3096 /*
3097 * Announce join success by sending
3098 * Join confirm to SME.
3099 */
3100 mlm_join_cnf.resultCode = eSIR_SME_SUCCESS;
3101 mlm_join_cnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3102 /* Update PE sessionId */
3103 mlm_join_cnf.sessionId = session_entry->peSessionId;
3104 lim_post_sme_message(mac_ctx, LIM_MLM_JOIN_CNF,
3105 (uint32_t *) &mlm_join_cnf);
3106
Abhinav Kumar2ae25242020-05-11 22:46:11 +05303107 if (session_entry->vhtCapability &&
3108 beacon_probe_rsp->vendor_vht_ie.VHTCaps.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 session_entry->is_vendor_specific_vhtcaps = true;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07003110 session_entry->vendor_specific_vht_ie_sub_type =
3111 beacon_probe_rsp->vendor_vht_ie.sub_type;
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003112 pe_debug("VHT caps are present in vendor specific IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 }
Nitesh Shah0ddd4f62016-05-27 10:07:32 +05303114
3115 /* Update HS 2.0 Information Element */
3116 if (beacon_probe_rsp->hs20vendor_ie.present) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003117 pe_debug("HS20 Indication Element Present, rel#:%u, id:%u",
Nitesh Shah0ddd4f62016-05-27 10:07:32 +05303118 beacon_probe_rsp->hs20vendor_ie.release_num,
3119 beacon_probe_rsp->hs20vendor_ie.hs_id_present);
3120 qdf_mem_copy(&session_entry->hs20vendor_ie,
3121 &beacon_probe_rsp->hs20vendor_ie,
3122 sizeof(tDot11fIEhs20vendor_ie) -
3123 sizeof(beacon_probe_rsp->hs20vendor_ie.hs_id));
3124 if (beacon_probe_rsp->hs20vendor_ie.hs_id_present)
3125 qdf_mem_copy(&session_entry->hs20vendor_ie.hs_id,
3126 &beacon_probe_rsp->hs20vendor_ie.hs_id,
3127 sizeof(beacon_probe_rsp->hs20vendor_ie.hs_id));
3128 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129}
3130
3131/**
3132 * lim_extract_ap_capabilities()
3133 *
3134 ***FUNCTION:
3135 * This function is called to extract all of the AP's capabilities
3136 * from the IEs received from it in Beacon/Probe Response frames
3137 *
3138 ***LOGIC:
3139 * This routine mimics the lim_extract_ap_capability() API. The difference here
3140 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3141 * left to the caller of this API to use this info as required
3142 *
3143 ***ASSUMPTIONS:
3144 * NA
3145 *
3146 ***NOTE:
3147 *
Jeff Johnsonab322b92018-11-21 23:10:49 -08003148 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 * @param pIE Pointer to starting IE in Beacon/Probe Response
3150 * @param ieLen Length of all IEs combined
3151 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3152 * populated
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003153 * @return status A status reporting QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003155QDF_STATUS lim_extract_ap_capabilities(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 uint8_t *pIE,
3157 uint16_t ieLen,
3158 tpSirProbeRespBeacon beaconStruct)
3159{
hangtian127c9532019-01-12 13:29:07 +08003160 qdf_mem_zero((uint8_t *) beaconStruct, sizeof(tSirProbeRespBeacon));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 /* Parse the Beacon IE's, Don't try to parse if we dont have anything in IE */
3163 if (ieLen > 0) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003164 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonab322b92018-11-21 23:10:49 -08003165 sir_parse_beacon_ie(mac, beaconStruct, pIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 (uint32_t) ieLen)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003167 pe_err("APCapExtract: Beacon parsing error!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003168 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 }
3170 }
3171
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003172 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173}
3174
3175/**
3176 * lim_del_bss()
3177 *
3178 ***FUNCTION:
3179 * This function is called to delete BSS context at hardware
3180 * whenever a STA is disassociated
3181 *
3182 ***LOGIC:
3183 *
3184 ***ASSUMPTIONS:
3185 * NA
3186 *
3187 ***NOTE:
3188 * NA
3189 *
Jeff Johnsonab322b92018-11-21 23:10:49 -08003190 * @param mac - Pointer to Global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003191 * @param sta - Pointer to the STA datastructure created by
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 * LIM and maintained by DPH
3193 * @return retCode - Indicates success or failure return code
3194 */
3195
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003196QDF_STATUS
Pragaspathi Thilagaraje05162d2019-05-23 13:10:46 +05303197lim_del_bss(struct mac_context *mac, tpDphHashNode sta, uint16_t bss_idx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003198 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003200 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003201 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 /* DPH was storing the AssocID in staID field, */
3204 /* staID is actually assigned by HAL when AddSTA message is sent. */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003205 if (sta) {
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003206 sta->valid = 0;
3207 sta->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Abhishek Ambure2bd960b2019-08-21 16:30:53 +05303208 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003209 pe_session->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003211 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 eLIM_MLM_WT_DEL_BSS_RSP_STATE));
3213
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003214 if ((pe_session->peSessionId ==
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303215 mac->lim.lim_timers.gLimJoinFailureTimer.sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 && (true ==
Pragaspathi Thilagaraj9f230382019-06-24 11:54:05 +05303217 tx_timer_running(&mac->lim.lim_timers.gLimJoinFailureTimer))) {
Jeff Johnsonab322b92018-11-21 23:10:49 -08003218 lim_deactivate_and_change_timer(mac, eLIM_JOIN_FAIL_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 }
3220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 /* we need to defer the message until we get the response back from HAL. */
Jeff Johnsonab322b92018-11-21 23:10:49 -08003222 SET_LIM_PROCESS_DEFD_MESGS(mac, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003224 if (pe_session->process_ho_fail)
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07003225 msgQ.type = WMA_DELETE_BSS_HO_FAIL_REQ;
3226 else
3227 msgQ.type = WMA_DELETE_BSS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 msgQ.reserved = 0;
Abhishek Ambure968f1512019-08-28 18:33:57 +05303229 msgQ.bodyptr = NULL;
3230 msgQ.bodyval = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07003232 pe_debug("Sessionid %d : Sending HAL_DELETE_BSS_REQ BSSID:" QDF_MAC_ADDR_FMT,
Abhishek Singh29405dc2020-02-17 13:08:32 +05303233 pe_session->peSessionId,
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07003234 QDF_MAC_ADDR_REF(pe_session->bssId));
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003235 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236
Jeff Johnsonab322b92018-11-21 23:10:49 -08003237 retCode = wma_post_ctrl_msg(mac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003238 if (QDF_STATUS_SUCCESS != retCode) {
Jeff Johnsonab322b92018-11-21 23:10:49 -08003239 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003240 pe_err("Posting DELETE_BSS_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 retCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 }
3243
3244 return retCode;
3245}
3246
3247/**
3248 * lim_update_vhtcaps_assoc_resp : Update VHT caps in assoc response.
3249 * @mac_ctx Pointer to Global MAC structure
3250 * @pAddBssParams: parameters required for add bss params.
3251 * @vht_caps: VHT capabilities.
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003252 * @pe_session : session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 *
3254 * Return : void
3255 */
sheenam monga6ab58a02020-06-29 15:43:45 +05303256void lim_update_vhtcaps_assoc_resp(struct mac_context *mac_ctx,
3257 struct bss_params *pAddBssParams,
3258 tDot11fIEVHTCaps *vht_caps,
3259 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260{
3261 pAddBssParams->staContext.vht_caps =
3262 ((vht_caps->maxMPDULen <<
3263 SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
3264 (vht_caps->supportedChannelWidthSet <<
3265 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
3266 (vht_caps->ldpcCodingCap <<
3267 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
3268 (vht_caps->shortGI80MHz <<
3269 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
3270 (vht_caps->shortGI160and80plus80MHz <<
3271 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
3272 (vht_caps->txSTBC <<
3273 SIR_MAC_VHT_CAP_TXSTBC) |
3274 (vht_caps->rxSTBC <<
3275 SIR_MAC_VHT_CAP_RXSTBC) |
3276 (vht_caps->suBeamFormerCap <<
3277 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
3278 (vht_caps->suBeamformeeCap <<
3279 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
3280 (vht_caps->csnofBeamformerAntSup <<
3281 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
3282 (vht_caps->numSoundingDim <<
3283 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
3284 (vht_caps->muBeamformerCap <<
3285 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
3286 (vht_caps->muBeamformeeCap <<
3287 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
3288 (vht_caps->vhtTXOPPS <<
3289 SIR_MAC_VHT_CAP_TXOPPS) |
3290 (vht_caps->htcVHTCap <<
3291 SIR_MAC_VHT_CAP_HTC_CAP) |
3292 (vht_caps->maxAMPDULenExp <<
3293 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
3294 (vht_caps->vhtLinkAdaptCap <<
3295 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
3296 (vht_caps->rxAntPattern <<
3297 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
3298 (vht_caps->txAntPattern <<
3299 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07003300 (vht_caps->extended_nss_bw_supp <<
3301 SIR_MAC_VHT_CAP_EXTD_NSS_BW));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302
3303 pAddBssParams->staContext.maxAmpduSize =
3304 SIR_MAC_GET_VHT_MAX_AMPDU_EXPO(
3305 pAddBssParams->staContext.vht_caps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306}
3307
3308/**
3309 * lim_update_vht_oper_assoc_resp : Update VHT Operations in assoc response.
3310 * @mac_ctx Pointer to Global MAC structure
3311 * @pAddBssParams: parameters required for add bss params.
3312 * @vht_oper: VHT Operations to update.
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003313 * @pe_session : session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 *
3315 * Return : void
3316 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003317static void lim_update_vht_oper_assoc_resp(struct mac_context *mac_ctx,
Jianmin Zhuf07aa512019-08-09 18:20:17 +08003318 struct bss_params *pAddBssParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003319 tDot11fIEVHTOperation *vht_oper, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320{
Liangwei Dong73fdb0d2019-12-13 15:01:00 +08003321 int16_t ccfs0 = vht_oper->chan_center_freq_seg0;
3322 int16_t ccfs1 = vht_oper->chan_center_freq_seg1;
3323 int16_t offset = abs((ccfs0 - ccfs1));
3324 uint8_t ch_width;
3325
3326 ch_width = pAddBssParams->ch_width;
3327 if (vht_oper->chanWidth && pe_session->ch_width) {
3328 ch_width = CH_WIDTH_80MHZ;
3329 if (ccfs1 && offset == 8)
3330 ch_width = CH_WIDTH_160MHZ;
3331 else if (ccfs1 && offset > 16)
3332 ch_width = CH_WIDTH_80P80MHZ;
3333 }
3334 if (ch_width > pe_session->ch_width)
3335 ch_width = pe_session->ch_width;
3336 pAddBssParams->ch_width = ch_width;
3337 pAddBssParams->staContext.ch_width = ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338}
3339
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07003340#ifdef WLAN_SUPPORT_TWT
3341/**
3342 * lim_set_sta_ctx_twt() - Save the TWT settings in STA context
3343 * @sta_ctx: Pointer to Station Context
3344 * @session: Pointer to PE session
3345 *
3346 * Return: None
3347 */
Jeff Johnsonec50d0d2018-11-18 22:19:01 -08003348static void lim_set_sta_ctx_twt(tAddStaParams *sta_ctx, struct pe_session *session)
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07003349{
3350 sta_ctx->twt_requestor = session->peer_twt_requestor;
3351 sta_ctx->twt_responder = session->peer_twt_responder;
3352}
3353#else
3354static inline void lim_set_sta_ctx_twt(tAddStaParams *sta_ctx,
Jeff Johnsonec50d0d2018-11-18 22:19:01 -08003355 struct pe_session *session)
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07003356{
3357}
3358#endif
3359
Abhinav Kumar4f959582019-08-13 12:50:20 +05303360void lim_sta_add_bss_update_ht_parameter(uint32_t bss_chan_freq,
Will Huang65d64252019-07-16 17:57:42 +08003361 tDot11fIEHTCaps* ht_cap,
3362 tDot11fIEHTInfo* ht_inf,
3363 bool chan_width_support,
Jianmin Zhuf07aa512019-08-09 18:20:17 +08003364 struct bss_params *add_bss)
Will Huang65d64252019-07-16 17:57:42 +08003365{
3366 if (!ht_cap->present)
3367 return;
3368
3369 add_bss->htCapable = ht_cap->present;
Will Huang65d64252019-07-16 17:57:42 +08003370
3371 if (!ht_inf->present)
3372 return;
3373
Abhishek Singh52dc8ab2019-09-25 17:53:41 +05303374 if (chan_width_support && ht_cap->supportedChannelWidthSet)
Will Huang65d64252019-07-16 17:57:42 +08003375 add_bss->ch_width = ht_inf->recommendedTxWidthSet;
Abhishek Singh52dc8ab2019-09-25 17:53:41 +05303376 else
Will Huang65d64252019-07-16 17:57:42 +08003377 add_bss->ch_width = CH_WIDTH_20MHZ;
Will Huang65d64252019-07-16 17:57:42 +08003378}
3379
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003380QDF_STATUS lim_sta_send_add_bss(struct mac_context *mac, tpSirAssocRsp pAssocRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 tpSchBeaconStruct pBeaconStruct,
Pragaspathi Thilagaraj1d8e2ab2019-03-04 23:59:21 +05303382 struct bss_description *bssDescription,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003383 uint8_t updateEntry, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384{
Jianmin Zhuf07aa512019-08-09 18:20:17 +08003385 struct bss_params *pAddBssParams = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 uint32_t retCode;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003387 tpDphHashNode sta = NULL;
Will Huang65d64252019-07-16 17:57:42 +08003388 bool chan_width_support = false;
Visweswara Tanuku2e2ac032018-04-12 11:25:11 +05303389 bool is_vht_cap_in_vendor_ie = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 tDot11fIEVHTCaps *vht_caps = NULL;
3391 tDot11fIEVHTOperation *vht_oper = NULL;
3392 tAddStaParams *sta_context;
Pragaspathi Thilagaraj3cf0f652018-10-29 16:40:35 +05303393 uint32_t listen_interval = MLME_CFG_LISTEN_INTERVAL;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05303394 struct mlme_vht_capabilities_info *vht_cap_info;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05303395
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05303396 vht_cap_info = &mac->mlme_cfg->vht_caps.vht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397
3398 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
Jianmin Zhuf07aa512019-08-09 18:20:17 +08003399 pAddBssParams = qdf_mem_malloc(sizeof(struct bss_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003400 if (!pAddBssParams) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003401 retCode = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 goto returnFailure;
Selvaraj, Sridhar6a8dcdf2016-10-19 15:53:58 +05303403 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303405 qdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3409
3410 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3411 pAddBssParams->updateBss = updateEntry;
3412
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003413 if (IS_DOT11_MODE_11B(pe_session->dot11mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 bssDescription->nwType != eSIR_11B_NW_TYPE) {
3415 pAddBssParams->nwType = eSIR_11B_NW_TYPE;
3416 } else {
3417 pAddBssParams->nwType = bssDescription->nwType;
3418 }
3419
3420 pAddBssParams->shortSlotTimeSupported =
3421 (uint8_t) pAssocRsp->capabilityInfo.shortSlotTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 pAddBssParams->llbCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003423 (uint8_t) pe_session->beaconParams.llbCoexist;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424
Vignesh Viswanathana8134622018-09-28 16:30:22 +05303425 /* Use the advertised capabilities from the received beacon/PR */
Will Huang65d64252019-07-16 17:57:42 +08003426 if (IS_DOT11_MODE_HT(pe_session->dot11mode)) {
3427 chan_width_support =
3428 lim_get_ht_capability(mac,
3429 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
3430 pe_session);
Abhinav Kumar4f959582019-08-13 12:50:20 +05303431 lim_sta_add_bss_update_ht_parameter(bssDescription->chan_freq,
Will Huang65d64252019-07-16 17:57:42 +08003432 &pAssocRsp->HTCaps,
3433 &pAssocRsp->HTInfo,
3434 chan_width_support,
3435 pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 }
3437
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003438 if (pe_session->vhtCapability && (pAssocRsp->VHTCaps.present)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3440 vht_caps = &pAssocRsp->VHTCaps;
3441 vht_oper = &pAssocRsp->VHTOperation;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003442 } else if (pe_session->vhtCapability &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303443 pAssocRsp->vendor_vht_ie.VHTCaps.present){
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 pAddBssParams->vhtCapable =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303445 pAssocRsp->vendor_vht_ie.VHTCaps.present;
Jeff Johnson179fd8a2018-05-11 14:20:05 -07003446 pe_debug("VHT Caps and Operation are present in vendor Specific IE");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303447 vht_caps = &pAssocRsp->vendor_vht_ie.VHTCaps;
3448 vht_oper = &pAssocRsp->vendor_vht_ie.VHTOperation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 } else {
3450 pAddBssParams->vhtCapable = 0;
3451 }
3452 if (pAddBssParams->vhtCapable) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003453 if (vht_oper)
Jeff Johnsonab322b92018-11-21 23:10:49 -08003454 lim_update_vht_oper_assoc_resp(mac, pAddBssParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003455 vht_oper, pe_session);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003456 if (vht_caps)
Jeff Johnsonab322b92018-11-21 23:10:49 -08003457 lim_update_vhtcaps_assoc_resp(mac, pAddBssParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003458 vht_caps, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 }
3460
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003461 if (lim_is_session_he_capable(pe_session) &&
Naveen Rawatd8feac12017-09-08 15:08:39 -07003462 (pAssocRsp->he_cap.present)) {
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08003463 lim_add_bss_he_cap(pAddBssParams, pAssocRsp);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003464 lim_add_bss_he_cfg(pAddBssParams, pe_session);
Manikandan Mohan39accff2017-05-02 16:09:00 -07003465 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 /*
3467 * Populate the STA-related parameters here
3468 * Note that the STA here refers to the AP
3469 * staType = PEER
3470 */
3471 sta_context = &pAddBssParams->staContext;
3472 /* Identifying AP as an STA */
3473 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
3474
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303475 qdf_mem_copy(pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 bssDescription->bssId, sizeof(tSirMacAddr));
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05303477
Jeff Johnsonab322b92018-11-21 23:10:49 -08003478 listen_interval = mac->mlme_cfg->sap_cfg.listen_interval;
Krunal Sonib3f45422017-07-24 18:59:45 -07003479 pAddBssParams->staContext.listenInterval = listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480
3481 /* Fill Assoc id from the dph table */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003482 sta = dph_lookup_hash_entry(mac, pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 &pAddBssParams->staContext.assocId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003484 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003485 if (!sta) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003486 pe_err("Couldn't get assoc id for " "MAC ADDR: "
Srinivas Girigowda0103acd2020-08-10 17:00:42 -07003487 QDF_MAC_ADDR_FMT,
3488 QDF_MAC_ADDR_REF(
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003489 pAddBssParams->staContext.staMac));
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003490 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 }
3492
3493 pAddBssParams->staContext.uAPSD =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003494 pe_session->gUapsdPerAcBitmask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495
3496 pAddBssParams->staContext.maxSPLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497 pAddBssParams->staContext.updateSta = updateEntry;
3498
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003499 if (IS_DOT11_MODE_HT(pe_session->dot11mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 && pBeaconStruct->HTCaps.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 pAddBssParams->staContext.htCapable = 1;
Jeff Johnsonbe119e62019-02-02 12:30:26 -08003502 if (pe_session->ht_config.ht_tx_stbc)
Arif Hussain53cf5692018-04-05 16:35:54 -07003503 pAddBssParams->staContext.stbc_capable =
3504 pAssocRsp->HTCaps.rxSTBC;
3505
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003506 if (pe_session->vhtCapability &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303508 IS_BSS_VHT_CAPABLE(pBeaconStruct->
3509 vendor_vht_ie.VHTCaps))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 pAddBssParams->staContext.vhtCapable = 1;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07003511 pAddBssParams->staContext.vht_mcs_10_11_supp =
3512 sta->vht_mcs_10_11_supp;
3513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 pAddBssParams->staContext.vhtSupportedRxNss =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003515 sta->vhtSupportedRxNss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 if (pAssocRsp->VHTCaps.present)
3517 vht_caps = &pAssocRsp->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303518 else if (pAssocRsp->vendor_vht_ie.VHTCaps.present) {
3519 vht_caps = &pAssocRsp->vendor_vht_ie.VHTCaps;
Jeff Johnson179fd8a2018-05-11 14:20:05 -07003520 pe_debug("VHT Caps are in vendor Specific IE");
Visweswara Tanuku2e2ac032018-04-12 11:25:11 +05303521 is_vht_cap_in_vendor_ie = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 }
3523
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003524 if ((vht_caps) && (vht_caps->suBeamFormerCap ||
Krunal Soni53993f72016-07-08 18:20:03 -07003525 vht_caps->muBeamformerCap) &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003526 pe_session->vht_config.su_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 sta_context->vhtTxBFCapable = 1;
3528
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003529 if ((vht_caps) && vht_caps->muBeamformerCap &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003530 pe_session->vht_config.mu_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 sta_context->vhtTxMUBformeeCapable = 1;
Krunal Soni53993f72016-07-08 18:20:03 -07003532
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003533 if ((vht_caps) && vht_caps->suBeamformeeCap &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003534 pe_session->vht_config.su_beam_former)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 sta_context->enable_su_tx_bformer = 1;
Arif Hussain53cf5692018-04-05 16:35:54 -07003536
3537 if (vht_caps && pAddBssParams->staContext.stbc_capable)
3538 pAddBssParams->staContext.stbc_capable =
3539 vht_caps->rxSTBC;
Kiran Kumar Lokerec220a512019-07-24 18:30:47 -07003540 if (pe_session->ch_width == CH_WIDTH_160MHZ ||
3541 pe_session->ch_width == CH_WIDTH_80P80MHZ) {
3542 sta_context->vht_160mhz_nss =
3543 sta->vht_160mhz_nss;
3544 sta_context->vht_80p80mhz_nss =
3545 sta->vht_80p80mhz_nss;
3546 sta_context->vht_extended_nss_bw_cap =
3547 sta->vht_extended_nss_bw_cap;
3548 } else {
3549 sta_context->vht_160mhz_nss = 0;
3550 sta_context->vht_80p80mhz_nss = 0;
3551 sta_context->vht_extended_nss_bw_cap = 0;
3552 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003554 if (lim_is_session_he_capable(pe_session) &&
Arif Hussain53cf5692018-04-05 16:35:54 -07003555 pAssocRsp->he_cap.present) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003556 lim_intersect_ap_he_caps(pe_session,
Arif Hussain53cf5692018-04-05 16:35:54 -07003557 pAddBssParams,
3558 NULL,
3559 pAssocRsp);
3560 lim_update_he_stbc_capable(&pAddBssParams->staContext);
3561 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562
Vignesh Viswanathana8134622018-09-28 16:30:22 +05303563 /*
3564 * in limExtractApCapability function intersection of FW
3565 * advertised channel width and AP advertised channel
3566 * width has been taken into account for calculating
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003567 * pe_session->ch_width
Vignesh Viswanathana8134622018-09-28 16:30:22 +05303568 */
Will Huang65d64252019-07-16 17:57:42 +08003569 if (chan_width_support &&
Vignesh Viswanathana8134622018-09-28 16:30:22 +05303570 ((pAssocRsp->HTCaps.supportedChannelWidthSet) ||
3571 (pBeaconStruct->HTCaps.supportedChannelWidthSet))) {
Liangwei Dong73fdb0d2019-12-13 15:01:00 +08003572 pAddBssParams->ch_width =
3573 pe_session->ch_width;
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08003574 pAddBssParams->staContext.ch_width =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003575 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 } else {
Liangwei Dong73fdb0d2019-12-13 15:01:00 +08003577 pAddBssParams->ch_width = CH_WIDTH_20MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578 sta_context->ch_width = CH_WIDTH_20MHZ;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05303579 if (!vht_cap_info->enable_txbf_20mhz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 sta_context->vhtTxBFCapable = 0;
3581 }
Vignesh Viswanathana8134622018-09-28 16:30:22 +05303582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 pAddBssParams->staContext.mimoPS =
3584 (tSirMacHTMIMOPowerSaveState)
3585 pAssocRsp->HTCaps.mimoPowerSave;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 pAddBssParams->staContext.maxAmpduDensity =
3587 pAssocRsp->HTCaps.mpduDensity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 /*
3589 * We will check gShortGI20Mhz and gShortGI40Mhz from
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003590 * session entry if they are set then we will use what ever
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 * Assoc response coming from AP supports. If these
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003592 * values are set as 0 in session entry then we will
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 * hardcode this values to 0.
3594 */
Jeff Johnsonbe119e62019-02-02 12:30:26 -08003595 if (pe_session->ht_config.ht_sgi20) {
Visweswara Tanuku2e2ac032018-04-12 11:25:11 +05303596 pAddBssParams->staContext.fShortGI20Mhz =
3597 (uint8_t)pAssocRsp->HTCaps.shortGI20MHz;
3598 } else {
3599 pAddBssParams->staContext.fShortGI20Mhz = false;
3600 }
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003601
Jeff Johnsonbe119e62019-02-02 12:30:26 -08003602 if (pe_session->ht_config.ht_sgi40) {
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003603 pAddBssParams->staContext.fShortGI40Mhz =
3604 (uint8_t) pAssocRsp->HTCaps.shortGI40MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 } else {
Visweswara Tanuku2e2ac032018-04-12 11:25:11 +05303606 pAddBssParams->staContext.fShortGI40Mhz = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 }
3608
3609 if (!pAddBssParams->staContext.vhtCapable)
3610 /* Use max ampd factor advertised in
3611 * HTCAP for non-vht connection */
3612 {
3613 pAddBssParams->staContext.maxAmpduSize =
3614 pAssocRsp->HTCaps.maxRxAMPDUFactor;
3615 } else if (pAddBssParams->staContext.maxAmpduSize <
3616 pAssocRsp->HTCaps.maxRxAMPDUFactor) {
3617 pAddBssParams->staContext.maxAmpduSize =
3618 pAssocRsp->HTCaps.maxRxAMPDUFactor;
3619 }
3620 if (pAddBssParams->staContext.vhtTxBFCapable
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05303621 && vht_cap_info->disable_ldpc_with_txbf_ap) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 pAddBssParams->staContext.htLdpcCapable = 0;
3623 pAddBssParams->staContext.vhtLdpcCapable = 0;
3624 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003625 if (pe_session->txLdpcIniFeatureEnabled & 0x1)
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003626 pAddBssParams->staContext.htLdpcCapable =
3627 (uint8_t) pAssocRsp->HTCaps.advCodingCap;
3628 else
3629 pAddBssParams->staContext.htLdpcCapable = 0;
3630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 if (pAssocRsp->VHTCaps.present)
3632 vht_caps = &pAssocRsp->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303633 else if (pAssocRsp->vendor_vht_ie.VHTCaps.present) {
3634 vht_caps = &pAssocRsp->vendor_vht_ie.VHTCaps;
Jeff Johnson179fd8a2018-05-11 14:20:05 -07003635 pe_debug("VHT Caps is in vendor Specific IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003637 if (vht_caps &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003638 (pe_session->txLdpcIniFeatureEnabled & 0x2)) {
Visweswara Tanuku2e2ac032018-04-12 11:25:11 +05303639 if (!is_vht_cap_in_vendor_ie)
3640 pAddBssParams->staContext.vhtLdpcCapable =
3641 (uint8_t) pAssocRsp->VHTCaps.ldpcCodingCap;
3642 else
3643 pAddBssParams->staContext.vhtLdpcCapable =
3644 (uint8_t) vht_caps->ldpcCodingCap;
3645 } else {
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003646 pAddBssParams->staContext.vhtLdpcCapable = 0;
Visweswara Tanuku2e2ac032018-04-12 11:25:11 +05303647 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 }
3649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 }
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08003651 if (lim_is_he_6ghz_band(pe_session)) {
3652 if (lim_is_session_he_capable(pe_session) &&
3653 pAssocRsp->he_cap.present) {
3654 lim_intersect_ap_he_caps(pe_session,
3655 pAddBssParams,
3656 NULL,
3657 pAssocRsp);
3658 lim_update_he_stbc_capable(&pAddBssParams->staContext);
Liangwei Dong2b0c18b2019-12-10 13:29:53 +08003659 lim_update_he_6gop_assoc_resp(pAddBssParams,
3660 &pAssocRsp->he_op,
3661 pe_session);
Amruta Kulkarni4edc97d2019-12-18 16:13:07 -08003662 lim_update_he_6ghz_band_caps(mac,
3663 &pAssocRsp->he_6ghz_band_cap,
3664 &pAddBssParams->staContext);
Kiran Kumar Lokere5abc59e2019-11-08 17:10:08 -08003665 }
3666 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 pAddBssParams->staContext.smesessionId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003668 pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 pAddBssParams->staContext.wpa_rsn = pBeaconStruct->rsnPresent;
3670 pAddBssParams->staContext.wpa_rsn |=
3671 (pBeaconStruct->wpaPresent << 1);
3672 /* For OSEN Connection AP does not advertise RSN or WPA IE
3673 * so from the IEs we get from supplicant we get this info
3674 * so for FW to transmit EAPOL message 4 we shall set
3675 * wpa_rsn
3676 */
3677 if ((!pAddBssParams->staContext.wpa_rsn)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003678 && (pe_session->isOSENConnection))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 pAddBssParams->staContext.wpa_rsn = 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303680 qdf_mem_copy(&pAddBssParams->staContext.capab_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 &pAssocRsp->capabilityInfo,
3682 sizeof(pAddBssParams->staContext.capab_info));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303683 qdf_mem_copy(&pAddBssParams->staContext.ht_caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 (uint8_t *) &pAssocRsp->HTCaps + sizeof(uint8_t),
3685 sizeof(pAddBssParams->staContext.ht_caps));
3686
3687 /* If WMM IE or 802.11E IE is present then enable WMM */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003688 if ((pe_session->limWmeEnabled && pAssocRsp->wmeEdcaPresent) ||
3689 (pe_session->limQosEnabled && pAssocRsp->edcaPresent))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 pAddBssParams->staContext.wmmEnabled = 1;
3691 else
3692 pAddBssParams->staContext.wmmEnabled = 0;
3693
3694 /* Update the rates */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003695 sta = dph_get_hash_entry(mac, DPH_STA_HASH_INDEX_PEER,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003696 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003697 if (sta) {
Jeff Johnsonecd4f212019-02-01 19:36:34 -08003698 qdf_mem_copy(&pAddBssParams->staContext.supportedRates,
3699 &sta->supportedRates,
3700 sizeof(sta->supportedRates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 } else
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07003702 pe_err("could not Update the supported rates");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003703 pAddBssParams->staContext.encryptType = pe_session->encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003705 pAddBssParams->maxTxPower = pe_session->maxTxPower;
Abhishek Singh9e0b8cd2020-02-06 13:35:28 +05303706
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303707 if (QDF_P2P_CLIENT_MODE == pe_session->opmode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 pAddBssParams->staContext.p2pCapableSta = 1;
3709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 pAddBssParams->extSetStaKeyParamValid = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711
3712#ifdef WLAN_FEATURE_11W
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003713 if (pe_session->limRmfEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 pAddBssParams->rmfEnabled = 1;
3715 pAddBssParams->staContext.rmfEnabled = 1;
3716 }
3717#endif
3718
3719 /* Set a new state for MLME */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003720 if (eLIM_MLM_WT_ASSOC_RSP_STATE == pe_session->limMlmState)
3721 pe_session->limMlmState =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
3723 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003724 pe_session->limMlmState =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
3726 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003727 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
3728 pe_session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003730 if (!pAddBssParams->staContext.htLdpcCapable)
3731 pAddBssParams->staContext.ht_caps &=
3732 ~(1 << SIR_MAC_HT_CAP_ADVCODING_S);
3733 if (!pAddBssParams->staContext.vhtLdpcCapable)
3734 pAddBssParams->staContext.vht_caps &=
3735 ~(1 << SIR_MAC_VHT_CAP_LDPC_CODING_CAP);
3736
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003737 if (pe_session->isNonRoamReassoc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738 pAddBssParams->nonRoamReassoc = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739
Abhishek Singh9e0b8cd2020-02-06 13:35:28 +05303740 pe_debug("update %d MxAmpduDen %d mimoPS %d vht_mcs11 %d shortSlot %d BI %d DTIM %d enc type %d p2p cab STA %d",
3741 updateEntry,
3742 pAddBssParams->staContext.maxAmpduDensity,
3743 pAddBssParams->staContext.mimoPS,
3744 pAddBssParams->staContext.vht_mcs_10_11_supp,
3745 pAddBssParams->shortSlotTimeSupported,
3746 pAddBssParams->beaconInterval, pAddBssParams->dtimPeriod,
3747 pAddBssParams->staContext.encryptType,
3748 pAddBssParams->staContext.p2pCapableSta);
Naveen Rawat64e477e2016-05-20 10:34:56 -07003749 if (cds_is_5_mhz_enabled()) {
3750 pAddBssParams->ch_width = CH_WIDTH_5MHZ;
3751 pAddBssParams->staContext.ch_width = CH_WIDTH_5MHZ;
3752 } else if (cds_is_10_mhz_enabled()) {
3753 pAddBssParams->ch_width = CH_WIDTH_10MHZ;
3754 pAddBssParams->staContext.ch_width = CH_WIDTH_10MHZ;
3755 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003756 lim_set_sta_ctx_twt(&pAddBssParams->staContext, pe_session);
Naveen Rawat64e477e2016-05-20 10:34:56 -07003757
bings11172832019-05-23 16:41:25 +08003758 if (lim_is_fils_connection(pe_session))
3759 pAddBssParams->no_ptk_4_way = true;
Abhishek Singh9e0b8cd2020-02-06 13:35:28 +05303760
3761 /* we need to defer the message until we get the response back */
3762 SET_LIM_PROCESS_DEFD_MESGS(mac, false);
bings11172832019-05-23 16:41:25 +08003763
Jianmin Zhu9772c4a2019-08-14 16:38:05 +08003764 retCode = wma_send_peer_assoc_req(pAddBssParams);
3765 if (QDF_IS_STATUS_ERROR(retCode)) {
Jeff Johnsonab322b92018-11-21 23:10:49 -08003766 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
Jianmin Zhu9772c4a2019-08-14 16:38:05 +08003767 pe_err("wma_send_peer_assoc_req failed=%X",
3768 retCode);
3769 }
Abhishek Singh6e5c7a62019-09-18 12:24:54 +05303770 qdf_mem_free(pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771
3772returnFailure:
3773 /* Clean-up will be done by the caller... */
3774 return retCode;
3775}
3776
Jianmin Zhu9772c4a2019-08-14 16:38:05 +08003777QDF_STATUS lim_sta_send_add_bss_pre_assoc(struct mac_context *mac,
3778 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779{
Jianmin Zhuf07aa512019-08-09 18:20:17 +08003780 struct bss_params *pAddBssParams = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 uint32_t retCode;
3782 tSchBeaconStruct *pBeaconStruct;
Will Huang65d64252019-07-16 17:57:42 +08003783 bool chan_width_support = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 tDot11fIEVHTOperation *vht_oper = NULL;
3785 tDot11fIEVHTCaps *vht_caps = NULL;
Pragaspathi Thilagaraj3cf0f652018-10-29 16:40:35 +05303786 uint32_t listen_interval = MLME_CFG_LISTEN_INTERVAL;
Pragaspathi Thilagaraj4af0b252020-07-16 19:54:53 +05303787 struct bss_description *bssDescription = NULL;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05303788 struct mlme_vht_capabilities_info *vht_cap_info;
3789
Pragaspathi Thilagaraj4af0b252020-07-16 19:54:53 +05303790 if (!pe_session->lim_join_req) {
3791 pe_err("Lim Join request is NULL");
3792 return QDF_STATUS_E_FAILURE;
3793 }
3794
3795 bssDescription = &pe_session->lim_join_req->bssDescription;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05303796 vht_cap_info = &mac->mlme_cfg->vht_caps.vht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303798 pBeaconStruct = qdf_mem_malloc(sizeof(tSchBeaconStruct));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003799 if (!pBeaconStruct)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003800 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801
3802 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
Jianmin Zhuf07aa512019-08-09 18:20:17 +08003803 pAddBssParams = qdf_mem_malloc(sizeof(struct bss_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003804 if (!pAddBssParams) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003805 retCode = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 goto returnFailure;
3807 }
3808
Jeff Johnsonab322b92018-11-21 23:10:49 -08003809 lim_extract_ap_capabilities(mac, (uint8_t *) bssDescription->ieFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 lim_get_ielen_from_bss_description(bssDescription),
3811 pBeaconStruct);
3812
Jeff Johnsonab322b92018-11-21 23:10:49 -08003813 if (mac->lim.gLimProtectionControl !=
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05303814 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnsonab322b92018-11-21 23:10:49 -08003815 lim_decide_sta_protection_on_assoc(mac, pBeaconStruct,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003816 pe_session);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303817 qdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818 sizeof(tSirMacAddr));
3819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3821
3822 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jianmin Zhu9772c4a2019-08-14 16:38:05 +08003823 pAddBssParams->updateBss = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 pAddBssParams->nwType = bssDescription->nwType;
3826
3827 pAddBssParams->shortSlotTimeSupported =
3828 (uint8_t) pBeaconStruct->capabilityInfo.shortSlotTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 pAddBssParams->llbCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003830 (uint8_t) pe_session->beaconParams.llbCoexist;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832 /* Use the advertised capabilities from the received beacon/PR */
Will Huang65d64252019-07-16 17:57:42 +08003833 if (IS_DOT11_MODE_HT(pe_session->dot11mode)) {
3834 chan_width_support =
3835 lim_get_ht_capability(mac,
3836 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
3837 pe_session);
Abhinav Kumar4f959582019-08-13 12:50:20 +05303838 lim_sta_add_bss_update_ht_parameter(bssDescription->chan_freq,
Will Huang65d64252019-07-16 17:57:42 +08003839 &pBeaconStruct->HTCaps,
3840 &pBeaconStruct->HTInfo,
3841 chan_width_support,
3842 pAddBssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843 }
3844
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003845 if (pe_session->vhtCapability &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303847 IS_BSS_VHT_CAPABLE(pBeaconStruct->vendor_vht_ie.VHTCaps))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848
3849 pAddBssParams->vhtCapable = 1;
3850 if (pBeaconStruct->VHTOperation.present)
3851 vht_oper = &pBeaconStruct->VHTOperation;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303852 else if (pBeaconStruct->vendor_vht_ie.VHTOperation.present) {
3853 vht_oper = &pBeaconStruct->vendor_vht_ie.VHTOperation;
Jeff Johnson179fd8a2018-05-11 14:20:05 -07003854 pe_debug("VHT Operation is present in vendor Specific IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 }
3856
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08003857 /*
3858 * in limExtractApCapability function intersection of FW
3859 * advertised channel width and AP advertised channel width has
3860 * been taken into account for calculating
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003861 * pe_session->ch_width
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08003862 */
3863 pAddBssParams->ch_width =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003864 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865 pAddBssParams->staContext.maxAmpduSize =
3866 SIR_MAC_GET_VHT_MAX_AMPDU_EXPO(
3867 pAddBssParams->staContext.vht_caps);
3868 } else {
3869 pAddBssParams->vhtCapable = 0;
3870 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08003871
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003872 if (lim_is_session_he_capable(pe_session) &&
Jingxiang Gef1d81592019-10-20 12:03:22 +08003873 pBeaconStruct->he_cap.present) {
3874 lim_update_bss_he_capable(mac, pAddBssParams);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003875 lim_add_bss_he_cfg(pAddBssParams, pe_session);
Jingxiang Gef1d81592019-10-20 12:03:22 +08003876 }
Abhishek Singh9e0b8cd2020-02-06 13:35:28 +05303877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 /*
3879 * Populate the STA-related parameters here
3880 * Note that the STA here refers to the AP
3881 */
3882 /* Identifying AP as an STA */
3883 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
3884
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303885 qdf_mem_copy(pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886 bssDescription->bssId, sizeof(tSirMacAddr));
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05303887
Jeff Johnsonab322b92018-11-21 23:10:49 -08003888 listen_interval = mac->mlme_cfg->sap_cfg.listen_interval;
Krunal Sonib3f45422017-07-24 18:59:45 -07003889 pAddBssParams->staContext.listenInterval = listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890 pAddBssParams->staContext.assocId = 0;
3891 pAddBssParams->staContext.uAPSD = 0;
3892 pAddBssParams->staContext.maxSPLen = 0;
Jianmin Zhu9772c4a2019-08-14 16:38:05 +08003893 pAddBssParams->staContext.updateSta = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003895 if (IS_DOT11_MODE_HT(pe_session->dot11mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 && (pBeaconStruct->HTCaps.present)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 pAddBssParams->staContext.htCapable = 1;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003898 if (pe_session->vhtCapability &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) ||
3900 IS_BSS_VHT_CAPABLE(
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303901 pBeaconStruct->vendor_vht_ie.VHTCaps))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902 pAddBssParams->staContext.vhtCapable = 1;
3903 if (pBeaconStruct->VHTCaps.present)
3904 vht_caps = &pBeaconStruct->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303905 else if (pBeaconStruct->vendor_vht_ie.VHTCaps.present)
3906 vht_caps = &pBeaconStruct->
3907 vendor_vht_ie.VHTCaps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003909 if ((vht_caps) && (vht_caps->suBeamFormerCap ||
Krunal Soni53993f72016-07-08 18:20:03 -07003910 vht_caps->muBeamformerCap) &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003911 pe_session->vht_config.su_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 pAddBssParams->staContext.vhtTxBFCapable = 1;
3913
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003914 if ((vht_caps) && vht_caps->muBeamformerCap &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003915 pe_session->vht_config.mu_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 pAddBssParams->staContext.vhtTxMUBformeeCapable
3917 = 1;
Krunal Soni53993f72016-07-08 18:20:03 -07003918
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003919 if ((vht_caps) && vht_caps->suBeamformeeCap &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003920 pe_session->vht_config.su_beam_former)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 pAddBssParams->staContext.enable_su_tx_bformer
3922 = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003924 if (lim_is_session_he_capable(pe_session) &&
Naveen Rawatd8feac12017-09-08 15:08:39 -07003925 pBeaconStruct->he_cap.present)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003926 lim_intersect_ap_he_caps(pe_session, pAddBssParams,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08003927 pBeaconStruct, NULL);
3928
Will Huang65d64252019-07-16 17:57:42 +08003929 if (pBeaconStruct->HTCaps.supportedChannelWidthSet &&
3930 chan_width_support) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 pAddBssParams->staContext.ch_width =
3932 (uint8_t) pBeaconStruct->HTInfo.
3933 recommendedTxWidthSet;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003934 if ((vht_oper) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935 pAddBssParams->staContext.vhtCapable &&
3936 vht_oper->chanWidth)
3937 pAddBssParams->staContext.ch_width =
3938 vht_oper->chanWidth + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 } else {
3940 pAddBssParams->staContext.ch_width =
3941 CH_WIDTH_20MHZ;
3942 }
3943 pAddBssParams->staContext.mimoPS =
3944 (tSirMacHTMIMOPowerSaveState) pBeaconStruct->HTCaps.
3945 mimoPowerSave;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946 pAddBssParams->staContext.maxAmpduDensity =
3947 pBeaconStruct->HTCaps.mpduDensity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 /*
3949 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3950 * if they are set then we will use what ever Beacon coming
3951 * from AP supports. If these values are set as 0 in ini file
3952 * then we will hardcode this values to 0.
3953 */
Jeff Johnsonbe119e62019-02-02 12:30:26 -08003954 if (pe_session->ht_config.ht_sgi20)
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003955 pAddBssParams->staContext.fShortGI20Mhz =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003956 (uint8_t)pBeaconStruct->HTCaps.shortGI20MHz;
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003957 else
Jeff Johnsonbe119e62019-02-02 12:30:26 -08003958 pAddBssParams->staContext.fShortGI20Mhz = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959
Jeff Johnsonbe119e62019-02-02 12:30:26 -08003960 if (pe_session->ht_config.ht_sgi40)
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07003961 pAddBssParams->staContext.fShortGI40Mhz =
3962 (uint8_t) pBeaconStruct->HTCaps.shortGI40MHz;
3963 else
3964 pAddBssParams->staContext.fShortGI40Mhz = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965
3966 pAddBssParams->staContext.maxAmpduSize =
3967 pBeaconStruct->HTCaps.maxRxAMPDUFactor;
3968 if (pAddBssParams->staContext.vhtTxBFCapable
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05303969 && vht_cap_info->disable_ldpc_with_txbf_ap) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970 pAddBssParams->staContext.htLdpcCapable = 0;
3971 pAddBssParams->staContext.vhtLdpcCapable = 0;
3972 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003973 if (pe_session->txLdpcIniFeatureEnabled & 0x1)
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003974 pAddBssParams->staContext.htLdpcCapable =
3975 (uint8_t) pBeaconStruct->HTCaps.
3976 advCodingCap;
3977 else
3978 pAddBssParams->staContext.htLdpcCapable = 0;
3979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 if (pBeaconStruct->VHTCaps.present)
3981 vht_caps = &pBeaconStruct->VHTCaps;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303982 else if (pBeaconStruct->vendor_vht_ie.VHTCaps.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 vht_caps =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303984 &pBeaconStruct->vendor_vht_ie.VHTCaps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003986 if (vht_caps &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003987 (pe_session->txLdpcIniFeatureEnabled & 0x2))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003988 pAddBssParams->staContext.vhtLdpcCapable =
3989 (uint8_t) vht_caps->ldpcCodingCap;
Kiran Kumar Lokere0413ba42015-11-03 14:08:09 -08003990 else
3991 pAddBssParams->staContext.vhtLdpcCapable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 }
3994 /*
3995 * If WMM IE or 802.11E IE is not present
3996 * and AP is HT AP then enable WMM
3997 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003998 if ((pe_session->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 pAddBssParams->staContext.htCapable)) ||
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004000 (pe_session->limQosEnabled &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 (pBeaconStruct->edcaPresent ||
4002 pAddBssParams->staContext.htCapable)))
4003 pAddBssParams->staContext.wmmEnabled = 1;
4004 else
4005 pAddBssParams->staContext.wmmEnabled = 0;
4006
4007 /* Update the rates */
Jeff Johnsonab322b92018-11-21 23:10:49 -08004008 lim_populate_peer_rate_set(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 &pAddBssParams->staContext.
4010 supportedRates,
4011 pBeaconStruct->HTCaps.supportedMCSSet,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004012 false, pe_session,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07004013 &pBeaconStruct->VHTCaps,
Pragaspathi Thilagaraj4af0b252020-07-16 19:54:53 +05304014 &pBeaconStruct->he_cap, NULL,
4015 bssDescription);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004017 pAddBssParams->staContext.encryptType = pe_session->encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004018
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004019 pAddBssParams->maxTxPower = pe_session->maxTxPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004021 pAddBssParams->staContext.smesessionId = pe_session->smeSessionId;
4022 pAddBssParams->staContext.sessionId = pe_session->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 pAddBssParams->extSetStaKeyParamValid = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004024
4025#ifdef WLAN_FEATURE_11W
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004026 if (pe_session->limRmfEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 pAddBssParams->rmfEnabled = 1;
4028 pAddBssParams->staContext.rmfEnabled = 1;
4029 }
4030#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 /* Set a new state for MLME */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004032 pe_session->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033
4034 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004035 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
4036 pe_session->limMlmState));
Naveen Rawat64e477e2016-05-20 10:34:56 -07004037 if (cds_is_5_mhz_enabled()) {
4038 pAddBssParams->ch_width = CH_WIDTH_5MHZ;
4039 pAddBssParams->staContext.ch_width = CH_WIDTH_5MHZ;
4040 } else if (cds_is_10_mhz_enabled()) {
4041 pAddBssParams->ch_width = CH_WIDTH_10MHZ;
4042 pAddBssParams->staContext.ch_width = CH_WIDTH_10MHZ;
4043 }
4044
bings11172832019-05-23 16:41:25 +08004045 if (lim_is_fils_connection(pe_session))
4046 pAddBssParams->no_ptk_4_way = true;
4047
Abhishek Singh7944c9a2019-09-18 17:55:22 +05304048 retCode = wma_pre_assoc_req(pAddBssParams);
4049 lim_process_sta_add_bss_rsp_pre_assoc(mac, pAddBssParams,
4050 pe_session, retCode);
Jianmin Zhu9772c4a2019-08-14 16:38:05 +08004051 qdf_mem_free(pAddBssParams);
Abhishek Singh7944c9a2019-09-18 17:55:22 +05304052 /*
4053 * Set retCode sucess as lim_process_sta_add_bss_rsp_pre_assoc take
4054 * care of failure
4055 */
Jianmin Zhu9772c4a2019-08-14 16:38:05 +08004056 retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057
4058returnFailure:
4059 /* Clean-up will be done by the caller... */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304060 qdf_mem_free(pBeaconStruct);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 return retCode;
4062}
4063
4064/**
4065 * lim_prepare_and_send_del_sta_cnf() - prepares and send del sta cnf
4066 *
Jeff Johnsonab322b92018-11-21 23:10:49 -08004067 * @mac: mac global context
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004068 * @sta: sta dph node
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304069 * @status_code: status code
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004070 * @pe_session: session context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 *
4072 * deletes DPH entry, changes the MLM mode for station, calls
4073 * lim_send_del_sta_cnf
4074 *
4075 * Return: void
4076 */
4077void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004078lim_prepare_and_send_del_sta_cnf(struct mac_context *mac, tpDphHashNode sta,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304079 tSirResultCodes status_code,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004080 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081{
4082 uint16_t staDsAssocId = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304083 struct qdf_mac_addr sta_dsaddr;
Pragaspathi Thilagarajb3d52532019-06-22 22:37:55 +05304084 struct lim_sta_context mlmStaContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004086 if (!sta) {
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004087 pe_err("sta is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 return;
4089 }
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004090 staDsAssocId = sta->assocId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_copy((uint8_t *) sta_dsaddr.bytes,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004092 sta->staAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004094 mlmStaContext = sta->mlmStaContext;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004095 if (LIM_IS_AP_ROLE(pe_session))
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004096 lim_release_peer_idx(mac, sta->assocId, pe_session);
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07004097
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08004098 lim_delete_dph_hash_entry(mac, sta->staAddr, sta->assocId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004099 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004101 if (LIM_IS_STA_ROLE(pe_session)) {
4102 pe_session->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsonab322b92018-11-21 23:10:49 -08004103 MTRACE(mac_trace(mac, TRACE_CODE_MLM_STATE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004104 pe_session->peSessionId,
4105 pe_session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 }
Jeff Johnsonab322b92018-11-21 23:10:49 -08004107 lim_send_del_sta_cnf(mac, sta_dsaddr, staDsAssocId, mlmStaContext,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304108 status_code, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109}
4110
4111/** -------------------------------------------------------------
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 \fn lim_init_pre_auth_timer_table
4113 \brief Initialize the Pre Auth Tanle and creates the timer for
4114 each node for the timeout value got from cfg.
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004115 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 \param tpLimPreAuthTable pPreAuthTimerTable
4117 \return none
4118 -------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004119void lim_init_pre_auth_timer_table(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 tpLimPreAuthTable pPreAuthTimerTable)
4121{
4122 uint32_t cfgValue;
4123 uint32_t authNodeIdx;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004124
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004125 tLimPreAuthNode **pAuthNode = pPreAuthTimerTable->pTable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126
4127 /* Get AUTH_RSP Timers value */
Jeff Johnsonab322b92018-11-21 23:10:49 -08004128 cfgValue = SYS_MS_TO_TICKS(mac->mlme_cfg->timeouts.auth_rsp_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 for (authNodeIdx = 0; authNodeIdx < pPreAuthTimerTable->numEntry;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004130 authNodeIdx++) {
Jeff Johnsonab322b92018-11-21 23:10:49 -08004131 if (tx_timer_create(mac, &(pAuthNode[authNodeIdx]->timer),
Naveen Rawat22b1a932015-08-26 12:13:18 -07004132 "AUTH RESPONSE TIMEOUT",
4133 lim_auth_response_timer_handler, authNodeIdx,
4134 cfgValue, 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004135 pe_err("Cannot create Auth Rsp timer of Index: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 authNodeIdx);
4137 return;
4138 }
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004139 pAuthNode[authNodeIdx]->authNodeIdx = (uint8_t) authNodeIdx;
4140 pAuthNode[authNodeIdx]->fFree = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142}
4143
4144/** -------------------------------------------------------------
4145 \fn lim_acquire_free_pre_auth_node
4146 \brief Retrives a free Pre Auth node from Pre Auth Table.
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004147 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 \param tpLimPreAuthTable pPreAuthTimerTable
4149 \return none
4150 -------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004151tLimPreAuthNode *lim_acquire_free_pre_auth_node(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 tpLimPreAuthTable pPreAuthTimerTable)
4153{
4154 uint32_t i;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004155 tLimPreAuthNode **pTempNode = pPreAuthTimerTable->pTable;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004156
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004157 for (i = 0; i < pPreAuthTimerTable->numEntry; i++) {
4158 if (pTempNode[i]->fFree == 1) {
4159 pTempNode[i]->fFree = 0;
4160 return pTempNode[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 }
4162 }
4163
4164 return NULL;
4165}
4166
4167/** -------------------------------------------------------------
4168 \fn lim_get_pre_auth_node_from_index
Jeff Johnson62018292018-05-06 16:18:35 -07004169 \brief Depending on the Index this retrieves the pre auth node.
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004170 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 \param tpLimPreAuthTable pAuthTable
4172 \param uint32_t authNodeIdx
4173 \return none
4174 -------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004175tLimPreAuthNode *lim_get_pre_auth_node_from_index(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 tpLimPreAuthTable pAuthTable,
4177 uint32_t authNodeIdx)
4178{
4179 if ((authNodeIdx >= pAuthTable->numEntry)
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004180 || (!pAuthTable->pTable)) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004181 pe_err("Invalid Auth Timer Index: %d NumEntry: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 authNodeIdx, pAuthTable->numEntry);
4183 return NULL;
4184 }
4185
Naveen Rawate6ddcaa2016-02-05 16:50:18 -08004186 return pAuthTable->pTable[authNodeIdx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187}
4188
4189/* Util API to check if the channels supported by STA is within range */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004190QDF_STATUS lim_is_dot11h_supported_channels_valid(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 tSirAssocReq *assoc)
4192{
4193 /*
4194 * Allow all the stations to join with us.
4195 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4196 * as an input into an algorithm used to select a new channel for the BSS.
4197 * The specification of the algorithm is beyond the scope of this amendment.
4198 */
4199
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004200 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201}
4202
4203/* Util API to check if the txpower supported by STA is within range */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004204QDF_STATUS lim_is_dot11h_power_capabilities_in_range(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205 tSirAssocReq *assoc,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004206 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207{
Amar Singhala297bfa2015-10-15 15:07:29 -07004208 int8_t localMaxTxPower;
Wu Gao5f764082019-01-04 15:54:38 +08004209 uint8_t local_pwr_constraint;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210
Amruta Kulkarniac761a62019-11-06 10:41:29 -08004211 localMaxTxPower = wlan_reg_get_channel_reg_power_for_freq(
4212 mac->pdev, pe_session->curr_op_freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
Wu Gao5f764082019-01-04 15:54:38 +08004214 local_pwr_constraint = mac->mlme_cfg->power.local_power_constraint;
4215 localMaxTxPower -= (int8_t)local_pwr_constraint;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216
4217 /**
4218 * The min Tx Power of the associating station should not be greater than (regulatory
4219 * max tx power - local power constraint configured on AP).
4220 */
4221 if (assoc->powerCapability.minTxPower > localMaxTxPower) {
Srinivas Girigowda9fad7da2017-03-26 13:24:39 -07004222 pe_warn("minTxPower (STA): %d, localMaxTxPower (AP): %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 assoc->powerCapability.minTxPower, localMaxTxPower);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004224 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 }
4226
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004227 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228}
4229
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004230void lim_fill_rx_highest_supported_rate(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 uint16_t *rxHighestRate,
4232 uint8_t *pSupportedMCSSet)
4233{
4234 tSirMacRxHighestSupportRate *pRxHighestRate;
4235 uint8_t *pBuf;
4236 uint16_t rate = 0;
4237
4238 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4239 rate = lim_get_u16(pBuf);
4240
4241 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4242 *rxHighestRate = pRxHighestRate->rate;
4243
4244 return;
4245}
4246
4247#ifdef WLAN_FEATURE_11W
4248/** -------------------------------------------------------------
4249 \fn lim_send_sme_unprotected_mgmt_frame_ind
4250 \brief Forwards the unprotected management frame to SME.
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004251 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252 \param frameType - 802.11 frame type
4253 \param frame - frame buffer
4254 \param sessionId - id for the current session
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004255 \param pe_session - PE session context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 \return none
4257 -------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004258void lim_send_sme_unprotected_mgmt_frame_ind(struct mac_context *mac, uint8_t frameType,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 uint8_t *frame, uint32_t frameLen,
4260 uint16_t sessionId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004261 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004263 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 tSirSmeUnprotMgmtFrameInd *pSirSmeMgmtFrame = NULL;
4265 uint16_t length;
4266
4267 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4268
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304269 pSirSmeMgmtFrame = qdf_mem_malloc(length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004270 if (!pSirSmeMgmtFrame)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272
4273 pSirSmeMgmtFrame->sessionId = sessionId;
4274 pSirSmeMgmtFrame->frameType = frameType;
4275
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304276 qdf_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 pSirSmeMgmtFrame->frameLen = frameLen;
4278
4279 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4280 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4281 mmhMsg.bodyval = 0;
4282
Jeff Johnsona5abe272019-01-06 12:52:02 -08004283 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 return;
4285}
4286#endif
4287
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004288#ifdef FEATURE_WLAN_ESE
Jeff Johnsone21b0eb2019-02-02 19:31:54 -08004289void lim_send_sme_tsm_ie_ind(struct mac_context *mac,
4290 struct pe_session *pe_session,
Jeff Johnson4f1b9152019-02-02 19:58:08 -08004291 uint8_t tid, uint8_t state,
4292 uint16_t measurement_interval)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293{
Jeff Johnson4f1b9152019-02-02 19:58:08 -08004294 struct scheduler_msg msg = {0};
4295 struct tsm_ie_ind *tsm_ie_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004297 if (!mac || !pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 return;
4299
Jeff Johnson4f1b9152019-02-02 19:58:08 -08004300 tsm_ie_ind = qdf_mem_malloc(sizeof(*tsm_ie_ind));
4301 if (!tsm_ie_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004303
Jeff Johnson4f1b9152019-02-02 19:58:08 -08004304 tsm_ie_ind->sessionId = pe_session->smeSessionId;
4305 tsm_ie_ind->tsm_ie.tsid = tid;
4306 tsm_ie_ind->tsm_ie.state = state;
4307 tsm_ie_ind->tsm_ie.msmt_interval = measurement_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308
Jeff Johnson4f1b9152019-02-02 19:58:08 -08004309 msg.type = eWNI_SME_TSM_IE_IND;
4310 msg.bodyptr = tsm_ie_ind;
4311 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312
Jeff Johnson4f1b9152019-02-02 19:58:08 -08004313 lim_sys_process_mmh_msg_api(mac, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004315#endif /* FEATURE_WLAN_ESE */
Srinivas Dasarid4e87252019-07-01 15:35:52 +05304316
4317void lim_extract_ies_from_deauth_disassoc(struct pe_session *session,
4318 uint8_t *deauth_disassoc_frame,
4319 uint16_t deauth_disassoc_frame_len)
4320{
4321 uint16_t reason_code, ie_offset;
4322 struct wlan_ies ie;
4323
4324 if (!session) {
4325 pe_err("NULL session");
4326 return;
4327 }
4328
4329 /* Get the offset of IEs */
4330 ie_offset = sizeof(struct wlan_frame_hdr) + sizeof(reason_code);
4331
4332 if (!deauth_disassoc_frame || deauth_disassoc_frame_len <= ie_offset)
4333 return;
4334
4335 ie.data = deauth_disassoc_frame + ie_offset;
4336 ie.len = deauth_disassoc_frame_len - ie_offset;
4337
4338 mlme_set_peer_disconnect_ies(session->vdev, &ie);
4339}
4340