blob: 4daec260cdbd2a233bacd3b95c80d6fb35f3b01c [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Paul Zhangc3fc0a82018-01-09 16:38:20 +08002 * Copyright (c) 2012-2018 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
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**=========================================================================
20
21 \brief implementation for PE 11r VoWiFi FT Protocol
22
23 ========================================================================*/
24
25/* $Header$ */
26
27/*--------------------------------------------------------------------------
28 Include Files
29 ------------------------------------------------------------------------*/
30#include <lim_send_messages.h>
31#include <lim_types.h>
32#include <lim_ft.h>
33#include <lim_ft_defs.h>
34#include <lim_utils.h>
35#include <lim_prop_exts_utils.h>
36#include <lim_assoc_utils.h>
37#include <lim_session.h>
38#include <lim_admit_control.h>
39#include "wmm_apsd.h"
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -070040#include "wma.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041
42extern void lim_send_set_sta_key_req(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053043 tLimMlmSetKeysReq * pMlmSetKeysReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044 uint16_t staIdx,
45 uint8_t defWEPIdx,
46 tpPESession sessionEntry, bool sendRsp);
47
48/*--------------------------------------------------------------------------
49 Initialize the FT variables.
50 ------------------------------------------------------------------------*/
51void lim_ft_open(tpAniSirGlobal pMac, tpPESession psessionEntry)
52{
53 if (psessionEntry)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053054 qdf_mem_set(&psessionEntry->ftPEContext, sizeof(tftPEContext),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055 0);
56}
57
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058void lim_ft_cleanup_all_ft_sessions(tpAniSirGlobal pMac)
59{
60 /* Wrapper function to cleanup all FT sessions */
61 int i;
62
63 for (i = 0; i < pMac->lim.maxBssId; i++) {
64 if (true == pMac->lim.gpSession[i].valid) {
65 /* The session is valid, may have FT data */
66 lim_ft_cleanup(pMac, &pMac->lim.gpSession[i]);
67 }
68 }
69}
70
71void lim_ft_cleanup(tpAniSirGlobal pMac, tpPESession psessionEntry)
72{
73 if (NULL == psessionEntry) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +053074 pe_err("psessionEntry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 return;
76 }
77
78 /* Nothing to be done if the session is not in STA mode */
79 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +053080 pe_err("psessionEntry is not in STA mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 return;
82 }
83
84 if (NULL != psessionEntry->ftPEContext.pFTPreAuthReq) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -070085 pe_debug("Freeing pFTPreAuthReq: %pK",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 psessionEntry->ftPEContext.pFTPreAuthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 if (NULL !=
88 psessionEntry->ftPEContext.pFTPreAuthReq->
89 pbssDescription) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053090 qdf_mem_free(psessionEntry->ftPEContext.pFTPreAuthReq->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 pbssDescription);
92 psessionEntry->ftPEContext.pFTPreAuthReq->
93 pbssDescription = NULL;
94 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053095 qdf_mem_free(psessionEntry->ftPEContext.pFTPreAuthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096 psessionEntry->ftPEContext.pFTPreAuthReq = NULL;
97 }
98
99 if (psessionEntry->ftPEContext.pAddBssReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530100 qdf_mem_free(psessionEntry->ftPEContext.pAddBssReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101 psessionEntry->ftPEContext.pAddBssReq = NULL;
102 }
103
104 if (psessionEntry->ftPEContext.pAddStaReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530105 qdf_mem_free(psessionEntry->ftPEContext.pAddStaReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106 psessionEntry->ftPEContext.pAddStaReq = NULL;
107 }
108
109 /* The session is being deleted, cleanup the contents */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530110 qdf_mem_set(&psessionEntry->ftPEContext, sizeof(tftPEContext), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111}
112
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800113#if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114/*------------------------------------------------------------------
115 *
116 * Create the new Add Bss Req to the new AP.
117 * This will be used when we are ready to FT to the new AP.
118 * The newly created ft Session entry is passed to this function
119 *
120 *------------------------------------------------------------------*/
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800121void lim_ft_prepare_add_bss_req(tpAniSirGlobal pMac,
122 uint8_t updateEntry, tpPESession pftSessionEntry,
123 tpSirBssDescription bssDescription)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124{
125 tpAddBssParams pAddBssParams = NULL;
126 tAddStaParams *sta_ctx;
127 uint8_t chanWidthSupp = 0;
128 tSchBeaconStruct *pBeaconStruct;
129
130 /* Nothing to be done if the session is not in STA mode */
131 if (!LIM_IS_STA_ROLE(pftSessionEntry)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530132 pe_err("psessionEntry is not in STA mode");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800133 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 }
135
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530136 pBeaconStruct = qdf_mem_malloc(sizeof(tSchBeaconStruct));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 if (NULL == pBeaconStruct) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530138 pe_err("Unable to allocate memory for creating ADD_BSS");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800139 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140 }
141 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530142 pAddBssParams = qdf_mem_malloc(sizeof(tAddBssParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 if (NULL == pAddBssParams) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530144 qdf_mem_free(pBeaconStruct);
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530145 pe_err("Unable to allocate memory for creating ADD_BSS");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800146 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147 }
148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 lim_extract_ap_capabilities(pMac, (uint8_t *) bssDescription->ieFields,
150 lim_get_ielen_from_bss_description(bssDescription),
151 pBeaconStruct);
152
153 if (pMac->lim.gLimProtectionControl !=
154 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
155 lim_decide_sta_protection_on_assoc(pMac, pBeaconStruct,
156 pftSessionEntry);
157
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530158 qdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 sizeof(tSirMacAddr));
160
161 /* Fill in tAddBssParams selfMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530162 qdf_mem_copy(pAddBssParams->selfMacAddr, pftSessionEntry->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 sizeof(tSirMacAddr));
164
165 pAddBssParams->bssType = pftSessionEntry->bssType;
166 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
167
168 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
169
170 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
171 pAddBssParams->updateBss = updateEntry;
172
173 pAddBssParams->reassocReq = true;
174
175 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
176 pAddBssParams->cfParamSet.cfpPeriod =
177 pBeaconStruct->cfParamSet.cfpPeriod;
178 pAddBssParams->cfParamSet.cfpMaxDuration =
179 pBeaconStruct->cfParamSet.cfpMaxDuration;
180 pAddBssParams->cfParamSet.cfpDurRemaining =
181 pBeaconStruct->cfParamSet.cfpDurRemaining;
182
183 pAddBssParams->rateSet.numRates =
184 pBeaconStruct->supportedRates.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530185 qdf_mem_copy(pAddBssParams->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 pBeaconStruct->supportedRates.rate,
187 pBeaconStruct->supportedRates.numRates);
188
189 pAddBssParams->nwType = bssDescription->nwType;
190
191 pAddBssParams->shortSlotTimeSupported =
192 (uint8_t) pBeaconStruct->capabilityInfo.shortSlotTime;
193 pAddBssParams->llaCoexist =
194 (uint8_t) pftSessionEntry->beaconParams.llaCoexist;
195 pAddBssParams->llbCoexist =
196 (uint8_t) pftSessionEntry->beaconParams.llbCoexist;
197 pAddBssParams->llgCoexist =
198 (uint8_t) pftSessionEntry->beaconParams.llgCoexist;
199 pAddBssParams->ht20Coexist =
200 (uint8_t) pftSessionEntry->beaconParams.ht20Coexist;
201#ifdef WLAN_FEATURE_11W
202 pAddBssParams->rmfEnabled = pftSessionEntry->limRmfEnabled;
203#endif
204
205 /* Use the advertised capabilities from the received beacon/PR */
206 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) &&
207 (pBeaconStruct->HTCaps.present)) {
208 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530209 qdf_mem_copy(&pAddBssParams->staContext.capab_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210 &pBeaconStruct->capabilityInfo,
211 sizeof(pAddBssParams->staContext.capab_info));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530212 qdf_mem_copy(&pAddBssParams->staContext.ht_caps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 (uint8_t *) &pBeaconStruct->HTCaps +
214 sizeof(uint8_t),
215 sizeof(pAddBssParams->staContext.ht_caps));
216
217 if (pBeaconStruct->HTInfo.present) {
218 pAddBssParams->htOperMode =
219 (tSirMacHTOperatingMode) pBeaconStruct->HTInfo.
220 opMode;
221 pAddBssParams->dualCTSProtection =
222 (uint8_t) pBeaconStruct->HTInfo.dualCTSProtection;
223
224 chanWidthSupp = lim_get_ht_capability(pMac,
225 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
226 pftSessionEntry);
227 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
228 (chanWidthSupp)) {
229 pAddBssParams->ch_width = (uint8_t)
230 pBeaconStruct->HTInfo.recommendedTxWidthSet;
231 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
232 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
233 pAddBssParams->ch_center_freq_seg0 =
234 bssDescription->channelId + 2;
235 else if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
236 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
237 pAddBssParams->ch_center_freq_seg0 =
238 bssDescription->channelId - 2;
239 } else {
240 pAddBssParams->ch_width = CH_WIDTH_20MHZ;
241 pAddBssParams->ch_center_freq_seg0 = 0;
242 }
243 pAddBssParams->llnNonGFCoexist =
244 (uint8_t) pBeaconStruct->HTInfo.nonGFDevicesPresent;
245 pAddBssParams->fLsigTXOPProtectionFullSupport =
246 (uint8_t) pBeaconStruct->HTInfo.
247 lsigTXOPProtectionFullSupport;
248 pAddBssParams->fRIFSMode =
249 pBeaconStruct->HTInfo.rifsMode;
250 }
251 }
252
253 pAddBssParams->currentOperChannel = bssDescription->channelId;
254 pftSessionEntry->htSecondaryChannelOffset =
255 pBeaconStruct->HTInfo.secondaryChannelOffset;
256 sta_ctx = &pAddBssParams->staContext;
257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 if (pftSessionEntry->vhtCapability &&
259 pftSessionEntry->vhtCapabilityPresentInBeacon) {
260 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
261 if (pBeaconStruct->VHTOperation.chanWidth && chanWidthSupp) {
262 pAddBssParams->ch_width =
263 pBeaconStruct->VHTOperation.chanWidth + 1;
264 pAddBssParams->ch_center_freq_seg0 =
265 pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
266 pAddBssParams->ch_center_freq_seg1 =
267 pBeaconStruct->VHTOperation.chanCenterFreqSeg2;
268 }
269 pAddBssParams->staContext.vht_caps =
270 ((pBeaconStruct->VHTCaps.maxMPDULen <<
271 SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
272 (pBeaconStruct->VHTCaps.supportedChannelWidthSet <<
273 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
274 (pBeaconStruct->VHTCaps.ldpcCodingCap <<
275 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
276 (pBeaconStruct->VHTCaps.shortGI80MHz <<
277 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
278 (pBeaconStruct->VHTCaps.shortGI160and80plus80MHz <<
279 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
280 (pBeaconStruct->VHTCaps.txSTBC <<
281 SIR_MAC_VHT_CAP_TXSTBC) |
282 (pBeaconStruct->VHTCaps.rxSTBC <<
283 SIR_MAC_VHT_CAP_RXSTBC) |
284 (pBeaconStruct->VHTCaps.suBeamFormerCap <<
285 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
286 (pBeaconStruct->VHTCaps.suBeamformeeCap <<
287 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
288 (pBeaconStruct->VHTCaps.csnofBeamformerAntSup <<
289 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
290 (pBeaconStruct->VHTCaps.numSoundingDim <<
291 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
292 (pBeaconStruct->VHTCaps.muBeamformerCap <<
293 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
294 (pBeaconStruct->VHTCaps.muBeamformeeCap <<
295 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
296 (pBeaconStruct->VHTCaps.vhtTXOPPS <<
297 SIR_MAC_VHT_CAP_TXOPPS) |
298 (pBeaconStruct->VHTCaps.htcVHTCap <<
299 SIR_MAC_VHT_CAP_HTC_CAP) |
300 (pBeaconStruct->VHTCaps.maxAMPDULenExp <<
301 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
302 (pBeaconStruct->VHTCaps.vhtLinkAdaptCap <<
303 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
304 (pBeaconStruct->VHTCaps.rxAntPattern <<
305 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
306 (pBeaconStruct->VHTCaps.txAntPattern <<
307 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
308 (pBeaconStruct->VHTCaps.reserved1 <<
309 SIR_MAC_VHT_CAP_RESERVED2));
310 } else {
311 pAddBssParams->vhtCapable = 0;
312 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530314 pe_debug("SIR_HAL_ADD_BSS_REQ with channel: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315 pAddBssParams->currentOperChannel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316
317 /* Populate the STA-related parameters here */
318 /* Note that the STA here refers to the AP */
319 {
320 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
321
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530322 qdf_mem_copy(pAddBssParams->staContext.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 bssDescription->bssId, sizeof(tSirMacAddr));
324 pAddBssParams->staContext.listenInterval =
325 bssDescription->beaconInterval;
326
327 pAddBssParams->staContext.assocId = 0;
328 pAddBssParams->staContext.uAPSD = 0;
329 pAddBssParams->staContext.maxSPLen = 0;
330 pAddBssParams->staContext.shortPreambleSupported =
331 (uint8_t) pBeaconStruct->capabilityInfo.shortPreamble;
332 pAddBssParams->staContext.updateSta = updateEntry;
333 pAddBssParams->staContext.encryptType =
334 pftSessionEntry->encryptType;
335#ifdef WLAN_FEATURE_11W
336 pAddBssParams->staContext.rmfEnabled =
337 pftSessionEntry->limRmfEnabled;
338#endif
339
340 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) &&
341 (pBeaconStruct->HTCaps.present)) {
342 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
343 pAddBssParams->staContext.htCapable = 1;
344 pAddBssParams->staContext.greenFieldCapable =
345 (uint8_t) pBeaconStruct->HTCaps.greenField;
346 pAddBssParams->staContext.lsigTxopProtection =
347 (uint8_t) pBeaconStruct->HTCaps.lsigTXOPProtection;
348 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
349 (chanWidthSupp)) {
350 pAddBssParams->staContext.ch_width = (uint8_t)
351 pBeaconStruct->HTInfo.recommendedTxWidthSet;
352 } else {
353 pAddBssParams->staContext.ch_width =
354 CH_WIDTH_20MHZ;
355 }
356 if (pftSessionEntry->vhtCapability &&
357 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps)) {
358 pAddBssParams->staContext.vhtCapable = 1;
359 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
360 pBeaconStruct->VHTCaps.muBeamformerCap) &&
Krunal Soni53993f72016-07-08 18:20:03 -0700361 pftSessionEntry->vht_config.su_beam_formee)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 sta_ctx->vhtTxBFCapable
363 = 1;
364 if (pBeaconStruct->VHTCaps.suBeamformeeCap &&
Krunal Soni53993f72016-07-08 18:20:03 -0700365 pftSessionEntry->vht_config.su_beam_former)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 sta_ctx->enable_su_tx_bformer = 1;
367 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800368 if (lim_is_session_he_capable(pftSessionEntry) &&
Naveen Rawatd8feac12017-09-08 15:08:39 -0700369 pBeaconStruct->he_cap.present)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800370 lim_intersect_ap_he_caps(pftSessionEntry,
371 pAddBssParams, pBeaconStruct, NULL);
372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
374 (chanWidthSupp)) {
375 sta_ctx->ch_width = (uint8_t)
376 pBeaconStruct->HTInfo.recommendedTxWidthSet;
377 if (pAddBssParams->staContext.vhtCapable &&
378 pBeaconStruct->VHTOperation.chanWidth)
379 sta_ctx->ch_width =
380 pBeaconStruct->VHTOperation.chanWidth
381 + 1;
382 } else {
383 pAddBssParams->staContext.ch_width =
384 CH_WIDTH_20MHZ;
385 }
386 pAddBssParams->staContext.mimoPS =
387 (tSirMacHTMIMOPowerSaveState) pBeaconStruct->HTCaps.
388 mimoPowerSave;
389 pAddBssParams->staContext.maxAmsduSize =
390 (uint8_t) pBeaconStruct->HTCaps.maximalAMSDUsize;
391 pAddBssParams->staContext.maxAmpduDensity =
392 pBeaconStruct->HTCaps.mpduDensity;
393 pAddBssParams->staContext.fDsssCckMode40Mhz =
394 (uint8_t) pBeaconStruct->HTCaps.dsssCckMode40MHz;
395 pAddBssParams->staContext.fShortGI20Mhz =
396 (uint8_t) pBeaconStruct->HTCaps.shortGI20MHz;
397 pAddBssParams->staContext.fShortGI40Mhz =
398 (uint8_t) pBeaconStruct->HTCaps.shortGI40MHz;
399 pAddBssParams->staContext.maxAmpduSize =
400 pBeaconStruct->HTCaps.maxRxAMPDUFactor;
401
402 if (pBeaconStruct->HTInfo.present)
403 pAddBssParams->staContext.rifsMode =
404 pBeaconStruct->HTInfo.rifsMode;
405 }
406
407 if ((pftSessionEntry->limWmeEnabled
408 && pBeaconStruct->wmeEdcaPresent)
409 || (pftSessionEntry->limQosEnabled
410 && pBeaconStruct->edcaPresent))
411 pAddBssParams->staContext.wmmEnabled = 1;
412 else
413 pAddBssParams->staContext.wmmEnabled = 0;
414
415 pAddBssParams->staContext.wpa_rsn = pBeaconStruct->rsnPresent;
416 /* For OSEN Connection AP does not advertise RSN or WPA IE
417 * so from the IEs we get from supplicant we get this info
418 * so for FW to transmit EAPOL message 4 we shall set
419 * wpa_rsn
420 */
421 pAddBssParams->staContext.wpa_rsn |=
422 (pBeaconStruct->wpaPresent << 1);
423 if ((!pAddBssParams->staContext.wpa_rsn)
424 && (pftSessionEntry->isOSENConnection))
425 pAddBssParams->staContext.wpa_rsn = 1;
426 /* Update the rates */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 lim_populate_peer_rate_set(pMac,
428 &pAddBssParams->staContext.
429 supportedRates,
430 pBeaconStruct->HTCaps.supportedMCSSet,
431 false, pftSessionEntry,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -0700432 &pBeaconStruct->VHTCaps,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700433 &pBeaconStruct->he_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 }
435
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 pAddBssParams->maxTxPower = pftSessionEntry->maxTxPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437
438#ifdef WLAN_FEATURE_11W
439 if (pftSessionEntry->limRmfEnabled) {
440 pAddBssParams->rmfEnabled = 1;
441 pAddBssParams->staContext.rmfEnabled = 1;
442 }
443#endif
444
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530445 pAddBssParams->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 pAddBssParams->respReqd = true;
447
448 pAddBssParams->staContext.sessionId = pftSessionEntry->peSessionId;
449 pAddBssParams->staContext.smesessionId = pftSessionEntry->smeSessionId;
450 pAddBssParams->sessionId = pftSessionEntry->peSessionId;
451
452 /* Set a new state for MLME */
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800453 if (!lim_is_roam_synch_in_progress(pftSessionEntry)) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800454 pftSessionEntry->limMlmState =
455 eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE;
456 MTRACE(mac_trace
457 (pMac, TRACE_CODE_MLM_STATE,
458 pftSessionEntry->peSessionId,
459 eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE));
460 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 pAddBssParams->halPersona = (uint8_t) pftSessionEntry->pePersona;
462
463 pftSessionEntry->ftPEContext.pAddBssReq = pAddBssParams;
464
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530465 pe_debug("Saving SIR_HAL_ADD_BSS_REQ for pre-auth ap");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530467 qdf_mem_free(pBeaconStruct);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800468 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800470#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471
Paul Zhangc3fc0a82018-01-09 16:38:20 +0800472#if defined(WLAN_FEATURE_ROAM_OFFLOAD)
Krunal Soni4bfecf62017-06-05 15:26:35 -0700473/**
474 * lim_fill_dot11mode() - to fill 802.11 mode in FT session
475 * @mac_ctx: pointer to mac ctx
476 * @pftSessionEntry: FT session
477 * @psessionEntry: PE session
478 *
479 * This API fills FT session's dot11mode either from pe session or
480 * from CFG depending on the condition.
481 *
482 * Return: none
483 */
484static void lim_fill_dot11mode(tpAniSirGlobal mac_ctx,
485 tpPESession pftSessionEntry, tpPESession psessionEntry)
486{
487 uint32_t self_dot11_mode;
488
489 if (psessionEntry->ftPEContext.pFTPreAuthReq &&
490 !mac_ctx->roam.configParam.isRoamOffloadEnabled) {
491 pftSessionEntry->dot11mode =
492 psessionEntry->ftPEContext.pFTPreAuthReq->dot11mode;
493 } else {
494 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_dot11_mode);
495 pe_debug("selfDot11Mode: %d", self_dot11_mode);
496 pftSessionEntry->dot11mode = self_dot11_mode;
497 }
498}
Paul Zhangc3fc0a82018-01-09 16:38:20 +0800499#elif defined(WLAN_FEATURE_HOST_ROAM)
Krunal Soni4bfecf62017-06-05 15:26:35 -0700500/**
501 * lim_fill_dot11mode() - to fill 802.11 mode in FT session
502 * @mac_ctx: pointer to mac ctx
503 * @pftSessionEntry: FT session
504 * @psessionEntry: PE session
505 *
506 * This API fills FT session's dot11mode either from pe session.
507 *
508 * Return: none
509 */
510static void lim_fill_dot11mode(tpAniSirGlobal mac_ctx,
511 tpPESession pftSessionEntry, tpPESession psessionEntry)
512{
513 pftSessionEntry->dot11mode =
514 psessionEntry->ftPEContext.pFTPreAuthReq->dot11mode;
515}
516#endif
517
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800518#if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519/*------------------------------------------------------------------
520 *
521 * Setup the new session for the pre-auth AP.
522 * Return the newly created session entry.
523 *
524 *------------------------------------------------------------------*/
525void lim_fill_ft_session(tpAniSirGlobal pMac,
526 tpSirBssDescription pbssDescription,
527 tpPESession pftSessionEntry, tpPESession psessionEntry)
528{
529 uint8_t currentBssUapsd;
Amar Singhala297bfa2015-10-15 15:07:29 -0700530 int8_t localPowerConstraint;
531 int8_t regMax;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800532 tSchBeaconStruct *pBeaconStruct;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533 ePhyChanBondState cbEnabledMode;
534
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530535 pBeaconStruct = qdf_mem_malloc(sizeof(tSchBeaconStruct));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 if (NULL == pBeaconStruct) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530537 pe_err("No memory for creating lim_fill_ft_session");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800538 return;
539 }
540
Deepak Dhamdhere26bda452016-01-09 22:54:48 -0800541 /* Retrieve the session that was already created and update the entry */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542 pftSessionEntry->limWmeEnabled = psessionEntry->limWmeEnabled;
543 pftSessionEntry->limQosEnabled = psessionEntry->limQosEnabled;
544 pftSessionEntry->limWsmEnabled = psessionEntry->limWsmEnabled;
545 pftSessionEntry->lim11hEnable = psessionEntry->lim11hEnable;
546 pftSessionEntry->isOSENConnection = psessionEntry->isOSENConnection;
547
548 /* Fields to be filled later */
549 pftSessionEntry->pLimJoinReq = NULL;
550 pftSessionEntry->smeSessionId = psessionEntry->smeSessionId;
551 pftSessionEntry->transactionId = 0;
552
553 lim_extract_ap_capabilities(pMac, (uint8_t *) pbssDescription->ieFields,
554 lim_get_ielen_from_bss_description(pbssDescription),
555 pBeaconStruct);
556
557 pftSessionEntry->rateSet.numRates =
558 pBeaconStruct->supportedRates.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530559 qdf_mem_copy(pftSessionEntry->rateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560 pBeaconStruct->supportedRates.rate,
561 pBeaconStruct->supportedRates.numRates);
562
563 pftSessionEntry->extRateSet.numRates =
564 pBeaconStruct->extendedRates.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530565 qdf_mem_copy(pftSessionEntry->extRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 pBeaconStruct->extendedRates.rate,
567 pftSessionEntry->extRateSet.numRates);
568
569 pftSessionEntry->ssId.length = pBeaconStruct->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530570 qdf_mem_copy(pftSessionEntry->ssId.ssId, pBeaconStruct->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 pftSessionEntry->ssId.length);
Krunal Soni4bfecf62017-06-05 15:26:35 -0700572 lim_fill_dot11mode(pMac, pftSessionEntry, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +0530574 pe_debug("dot11mode: %d", pftSessionEntry->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 pftSessionEntry->vhtCapability =
576 (IS_DOT11_MODE_VHT(pftSessionEntry->dot11mode)
577 && IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps));
578 pftSessionEntry->htCapability =
579 (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode)
580 && pBeaconStruct->HTCaps.present);
581
582 /* Copy The channel Id to the session Table */
583 pftSessionEntry->limReassocChannelId = pbssDescription->channelId;
584 pftSessionEntry->currentOperChannel = pbssDescription->channelId;
585
586 pftSessionEntry->limRFBand = lim_get_rf_band(
587 pftSessionEntry->currentOperChannel);
588
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800589 if (pftSessionEntry->limRFBand == BAND_2G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 cbEnabledMode = pMac->roam.configParam.channelBondingMode24GHz;
591 } else {
592 cbEnabledMode = pMac->roam.configParam.channelBondingMode5GHz;
593 }
594 pftSessionEntry->htSupportedChannelWidthSet =
595 (pBeaconStruct->HTInfo.present) ?
596 (cbEnabledMode && pBeaconStruct->HTInfo.recommendedTxWidthSet) : 0;
597 pftSessionEntry->htRecommendedTxWidthSet =
598 pftSessionEntry->htSupportedChannelWidthSet;
599
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 if (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) &&
601 pBeaconStruct->VHTOperation.present &&
602 pftSessionEntry->vhtCapability) {
603 pftSessionEntry->vhtCapabilityPresentInBeacon = 1;
604 } else {
605 pftSessionEntry->vhtCapabilityPresentInBeacon = 0;
606 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 if (pftSessionEntry->htRecommendedTxWidthSet) {
608 pftSessionEntry->ch_width = CH_WIDTH_40MHZ;
609 if (pftSessionEntry->vhtCapabilityPresentInBeacon &&
610 pBeaconStruct->VHTOperation.chanWidth) {
611 pftSessionEntry->ch_width =
612 pBeaconStruct->VHTOperation.chanWidth + 1;
613 pftSessionEntry->ch_center_freq_seg0 =
614 pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
615 pftSessionEntry->ch_center_freq_seg1 =
616 pBeaconStruct->VHTOperation.chanCenterFreqSeg2;
617 } else {
618 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
619 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
620 pftSessionEntry->ch_center_freq_seg0 =
621 pbssDescription->channelId + 2;
622 else if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
623 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
624 pftSessionEntry->ch_center_freq_seg0 =
625 pbssDescription->channelId - 2;
626 else
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530627 pe_warn("Invalid sec ch offset");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628 }
629 } else {
630 pftSessionEntry->ch_width = CH_WIDTH_20MHZ;
631 pftSessionEntry->ch_center_freq_seg0 = 0;
632 pftSessionEntry->ch_center_freq_seg1 = 0;
633 }
634
635 sir_copy_mac_addr(pftSessionEntry->selfMacAddr,
636 psessionEntry->selfMacAddr);
637 sir_copy_mac_addr(pftSessionEntry->limReAssocbssId,
638 pbssDescription->bssId);
639 sir_copy_mac_addr(pftSessionEntry->prev_ap_bssid, psessionEntry->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640
641 /* Store beaconInterval */
642 pftSessionEntry->beaconParams.beaconInterval =
643 pbssDescription->beaconInterval;
644 pftSessionEntry->bssType = psessionEntry->bssType;
645
646 pftSessionEntry->statypeForBss = STA_ENTRY_PEER;
647 pftSessionEntry->nwType = pbssDescription->nwType;
648
649
650 if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE) {
651 pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 } else {
Rajeev Kumar005895d2016-04-15 14:17:47 -0700653 /* Throw an error & return & make sure to delete the session */
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530654 pe_warn("Invalid bss type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 }
656
657 pftSessionEntry->limCurrentBssCaps = pbssDescription->capabilityInfo;
658 pftSessionEntry->limReassocBssCaps = pbssDescription->capabilityInfo;
659 if (pMac->roam.configParam.shortSlotTime &&
660 SIR_MAC_GET_SHORT_SLOT_TIME(pftSessionEntry->limReassocBssCaps)) {
661 pftSessionEntry->shortSlotTimeSupported = true;
662 }
663
664 regMax = cfg_get_regulatory_max_transmit_power(pMac,
665 pftSessionEntry->
666 currentOperChannel);
667 localPowerConstraint = regMax;
668 lim_extract_ap_capability(pMac, (uint8_t *) pbssDescription->ieFields,
669 lim_get_ielen_from_bss_description(pbssDescription),
670 &pftSessionEntry->limCurrentBssQosCaps,
671 &pftSessionEntry->limCurrentBssPropCap, &currentBssUapsd,
672 &localPowerConstraint, pftSessionEntry);
673
674 pftSessionEntry->limReassocBssQosCaps =
675 pftSessionEntry->limCurrentBssQosCaps;
676 pftSessionEntry->limReassocBssPropCap =
677 pftSessionEntry->limCurrentBssPropCap;
678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 pftSessionEntry->is11Rconnection = psessionEntry->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680#ifdef FEATURE_WLAN_ESE
681 pftSessionEntry->isESEconnection = psessionEntry->isESEconnection;
682 pftSessionEntry->is_ese_version_ie_present =
683 pBeaconStruct->is_ese_ver_ie_present;
684#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 pftSessionEntry->isFastTransitionEnabled =
686 psessionEntry->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 pftSessionEntry->isFastRoamIniFeatureEnabled =
689 psessionEntry->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690
691#ifdef FEATURE_WLAN_ESE
692 pftSessionEntry->maxTxPower =
693 lim_get_max_tx_power(regMax, localPowerConstraint,
694 pMac->roam.configParam.nTxPowerCap);
695#else
Anurag Chouhan6d760662016-02-20 16:05:43 +0530696 pftSessionEntry->maxTxPower = QDF_MIN(regMax, (localPowerConstraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697#endif
698
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530699 pe_debug("Reg max: %d local pwr: %d, ini tx pwr: %d max tx pwr: %d",
Deepak Dhamdhere26bda452016-01-09 22:54:48 -0800700 regMax, localPowerConstraint,
701 pMac->roam.configParam.nTxPowerCap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 pftSessionEntry->maxTxPower);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800703 if (!lim_is_roam_synch_in_progress(psessionEntry)) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800704 pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
705 pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
706 MTRACE(mac_trace(pMac,
707 TRACE_CODE_SME_STATE,
708 pftSessionEntry->peSessionId,
709 pftSessionEntry->limSmeState));
710 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800711 pftSessionEntry->encryptType = psessionEntry->encryptType;
712#ifdef WLAN_FEATURE_11W
713 pftSessionEntry->limRmfEnabled = psessionEntry->limRmfEnabled;
714#endif
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800715 if ((pftSessionEntry->limRFBand == BAND_2G) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -0800716 (pftSessionEntry->htSupportedChannelWidthSet ==
717 eHT_CHANNEL_WIDTH_40MHZ))
718 lim_init_obss_params(pMac, pftSessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800720 pftSessionEntry->enableHtSmps = psessionEntry->enableHtSmps;
Archana Ramachandranb66fc732016-03-30 16:26:38 -0700721 pftSessionEntry->htSmpsvalue = psessionEntry->htSmpsvalue;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -0700722 /*
723 * By default supported NSS 1x1 is set to true
724 * and later on updated while determining session
725 * supported rates which is the intersection of
726 * self and peer rates
727 */
728 pftSessionEntry->supported_nss_1x1 = true;
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530729 pe_debug("FT enable smps: %d mode: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800730 pftSessionEntry->enableHtSmps,
Archana Ramachandranb66fc732016-03-30 16:26:38 -0700731 pftSessionEntry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -0700732 pftSessionEntry->supported_nss_1x1);
733
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530734 qdf_mem_free(pBeaconStruct);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -0800736#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737
738/*------------------------------------------------------------------
739 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 * This function is called to process the update key request from SME
741 *
742 *------------------------------------------------------------------*/
743bool lim_process_ft_update_key(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
744{
745 tAddBssParams *pAddBssParams;
746 tSirFTUpdateKeyInfo *pKeyInfo;
747 uint32_t val = 0;
748 tpPESession psessionEntry;
749 uint8_t sessionId;
750
751 /* Sanity Check */
752 if (pMac == NULL || pMsgBuf == NULL) {
753 return false;
754 }
755
756 pKeyInfo = (tSirFTUpdateKeyInfo *) pMsgBuf;
757
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -0800758 psessionEntry = pe_find_session_by_bssid(pMac, pKeyInfo->bssid.bytes,
759 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 if (NULL == psessionEntry) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530761 pe_err("%s: Unable to find session for the following bssid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 __func__);
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -0800763 lim_print_mac_addr(pMac, pKeyInfo->bssid.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 return false;
765 }
766
767 /* Nothing to be done if the session is not in STA mode */
768 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530769 pe_err("psessionEntry is not in STA mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 return false;
771 }
772
773 if (NULL == psessionEntry->ftPEContext.pAddBssReq) {
774 /* AddBss Req is NULL, save the keys to configure them later. */
775 tpLimMlmSetKeysReq pMlmSetKeysReq =
776 &psessionEntry->ftPEContext.PreAuthKeyInfo.
777 extSetStaKeyParam;
778
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530779 qdf_mem_zero(pMlmSetKeysReq, sizeof(tLimMlmSetKeysReq));
Anurag Chouhanc5548422016-02-24 18:33:27 +0530780 qdf_copy_macaddr(&pMlmSetKeysReq->peer_macaddr,
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -0800781 &pKeyInfo->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 pMlmSetKeysReq->sessionId = psessionEntry->peSessionId;
783 pMlmSetKeysReq->smesessionId = psessionEntry->smeSessionId;
784 pMlmSetKeysReq->edType = pKeyInfo->keyMaterial.edType;
785 pMlmSetKeysReq->numKeys = pKeyInfo->keyMaterial.numKeys;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530786 qdf_mem_copy((uint8_t *) &pMlmSetKeysReq->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787 (uint8_t *) &pKeyInfo->keyMaterial.key,
788 sizeof(tSirKeys));
789
790 psessionEntry->ftPEContext.PreAuthKeyInfo.
791 extSetStaKeyParamValid = true;
792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 if (psessionEntry->ftPEContext.pAddStaReq == NULL) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530794 pe_err("pAddStaReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 lim_send_set_sta_key_req(pMac, pMlmSetKeysReq, 0, 0,
796 psessionEntry, false);
797 psessionEntry->ftPEContext.PreAuthKeyInfo.
798 extSetStaKeyParamValid = false;
799 }
800 } else {
801 pAddBssParams = psessionEntry->ftPEContext.pAddBssReq;
802
803 /* Store the key information in the ADD BSS parameters */
804 pAddBssParams->extSetStaKeyParamValid = 1;
805 pAddBssParams->extSetStaKeyParam.encType =
806 pKeyInfo->keyMaterial.edType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_copy((uint8_t *) &pAddBssParams->extSetStaKeyParam.key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 (uint8_t *) &pKeyInfo->keyMaterial.key,
809 sizeof(tSirKeys));
810 if (eSIR_SUCCESS !=
811 wlan_cfg_get_int(pMac, WNI_CFG_SINGLE_TID_RC, &val)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530812 pe_warn("Unable to read WNI_CFG_SINGLE_TID_RC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 }
814
815 pAddBssParams->extSetStaKeyParam.singleTidRc = val;
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530816 pe_debug("Key valid: %d keyLength: %d",
Nishank Aggarwalabfd70b2017-03-11 16:48:25 +0530817 pAddBssParams->extSetStaKeyParamValid,
818 pAddBssParams->extSetStaKeyParam.key[0].keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819
820 pAddBssParams->extSetStaKeyParam.staIdx = 0;
821
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530822 pe_debug("BSSID: " MAC_ADDRESS_STR,
Nishank Aggarwalabfd70b2017-03-11 16:48:25 +0530823 MAC_ADDR_ARRAY(pKeyInfo->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824
Anurag Chouhanc5548422016-02-24 18:33:27 +0530825 qdf_copy_macaddr(&pAddBssParams->extSetStaKeyParam.peer_macaddr,
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -0800826 &pKeyInfo->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827
828 pAddBssParams->extSetStaKeyParam.sendRsp = false;
829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 }
831 return true;
832}
833
Jeff Johnson4f9d4a22016-10-06 18:45:15 -0700834static void
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835lim_ft_send_aggr_qos_rsp(tpAniSirGlobal pMac, uint8_t rspReqd,
836 tpAggrAddTsParams aggrQosRsp, uint8_t smesessionId)
837{
838 tpSirAggrQosRsp rsp;
839 int i = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 if (!rspReqd) {
842 return;
843 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530844 rsp = qdf_mem_malloc(sizeof(tSirAggrQosRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 if (NULL == rsp) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530846 pe_err("AllocateMemory failed for tSirAggrQosRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 return;
848 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 rsp->messageType = eWNI_SME_FT_AGGR_QOS_RSP;
850 rsp->sessionId = smesessionId;
851 rsp->length = sizeof(*rsp);
852 rsp->aggrInfo.tspecIdx = aggrQosRsp->tspecIdx;
853 for (i = 0; i < SIR_QOS_NUM_AC_MAX; i++) {
854 if ((1 << i) & aggrQosRsp->tspecIdx) {
Naveen Rawat25735af2017-07-05 15:24:28 -0700855 if (QDF_IS_STATUS_SUCCESS(aggrQosRsp->status[i]))
856 rsp->aggrInfo.aggrRsp[i].status =
857 eSIR_MAC_SUCCESS_STATUS;
858 else
859 rsp->aggrInfo.aggrRsp[i].status =
860 eSIR_MAC_UNSPEC_FAILURE_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 rsp->aggrInfo.aggrRsp[i].tspec = aggrQosRsp->tspec[i];
862 }
863 }
864 lim_send_sme_aggr_qos_rsp(pMac, rsp, smesessionId);
865 return;
866}
Varun Reddy Yeturudbbb9912016-02-10 14:32:50 -0800867
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800868void lim_process_ft_aggr_qo_s_rsp(tpAniSirGlobal pMac,
869 struct scheduler_msg *limMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870{
871 tpAggrAddTsParams pAggrQosRspMsg = NULL;
872 tAddTsParams addTsParam = { 0 };
873 tpDphHashNode pSta = NULL;
874 uint16_t assocId = 0;
875 tSirMacAddr peerMacAddr;
876 uint8_t rspReqd = 1;
877 tpPESession psessionEntry = NULL;
878 int i = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700879
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530880 pe_debug(" Received AGGR_QOS_RSP from HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
882 pAggrQosRspMsg = (tpAggrAddTsParams) (limMsg->bodyptr);
883 if (NULL == pAggrQosRspMsg) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530884 pe_err("NULL pAggrQosRspMsg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 return;
886 }
887 psessionEntry =
888 pe_find_session_by_session_id(pMac, pAggrQosRspMsg->sessionId);
889 if (NULL == psessionEntry) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530890 pe_err("Cant find session entry for %s", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 if (pAggrQosRspMsg != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530892 qdf_mem_free(pAggrQosRspMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 }
894 return;
895 }
896 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530897 pe_err("psessionEntry is not in STA mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 return;
899 }
900 for (i = 0; i < HAL_QOS_NUM_AC_MAX; i++) {
901 if ((((1 << i) & pAggrQosRspMsg->tspecIdx)) &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530902 (pAggrQosRspMsg->status[i] != QDF_STATUS_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 sir_copy_mac_addr(peerMacAddr, psessionEntry->bssId);
904 addTsParam.staIdx = pAggrQosRspMsg->staIdx;
905 addTsParam.sessionId = pAggrQosRspMsg->sessionId;
906 addTsParam.tspec = pAggrQosRspMsg->tspec[i];
907 addTsParam.tspecIdx = pAggrQosRspMsg->tspecIdx;
908 lim_send_delts_req_action_frame(pMac, peerMacAddr, rspReqd,
909 &addTsParam.tspec.tsinfo,
910 &addTsParam.tspec,
911 psessionEntry);
912 pSta =
913 dph_lookup_assoc_id(pMac, addTsParam.staIdx, &assocId,
914 &psessionEntry->dph.dphHashTable);
915 if (pSta != NULL) {
916 lim_admit_control_delete_ts(pMac, assocId,
917 &addTsParam.tspec.
918 tsinfo, NULL,
919 (uint8_t *) &
920 addTsParam.tspecIdx);
921 }
922 }
923 }
924 lim_ft_send_aggr_qos_rsp(pMac, rspReqd, pAggrQosRspMsg,
925 psessionEntry->smeSessionId);
926 if (pAggrQosRspMsg != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530927 qdf_mem_free(pAggrQosRspMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 }
929 return;
930}
Varun Reddy Yeturudbbb9912016-02-10 14:32:50 -0800931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932tSirRetStatus lim_process_ft_aggr_qos_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
933{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700934 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 tSirAggrQosReq *aggrQosReq = (tSirAggrQosReq *) pMsgBuf;
936 tpAggrAddTsParams pAggrAddTsParam;
937 tpPESession psessionEntry = NULL;
938 tpLimTspecInfo tspecInfo;
939 uint8_t ac;
940 tpDphHashNode pSta;
941 uint16_t aid;
942 uint8_t sessionId;
943 int i;
944
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530945 pAggrAddTsParam = qdf_mem_malloc(sizeof(tAggrAddTsParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 if (NULL == pAggrAddTsParam) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530947 pe_err("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 return eSIR_MEM_ALLOC_FAILED;
949 }
950
Srinivas Girigowda99faf482015-12-03 19:06:15 -0800951 psessionEntry = pe_find_session_by_bssid(pMac, aggrQosReq->bssid.bytes,
952 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953
954 if (psessionEntry == NULL) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530955 pe_err("psession Entry Null for sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 aggrQosReq->sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530957 qdf_mem_free(pAggrAddTsParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 return eSIR_FAILURE;
959 }
960
961 /* Nothing to be done if the session is not in STA mode */
962 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530963 pe_err("psessionEntry is not in STA mode");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 qdf_mem_free(pAggrAddTsParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 return eSIR_FAILURE;
966 }
967
Srinivas Girigowda99faf482015-12-03 19:06:15 -0800968 pSta = dph_lookup_hash_entry(pMac, aggrQosReq->bssid.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 &psessionEntry->dph.dphHashTable);
970 if (pSta == NULL) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +0530971 pe_err("Station context not found - ignoring AddTsRsp");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 qdf_mem_free(pAggrAddTsParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 return eSIR_FAILURE;
974 }
975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976 pAggrAddTsParam->staIdx = psessionEntry->staId;
977 /* Fill in the sessionId specific to PE */
978 pAggrAddTsParam->sessionId = sessionId;
979 pAggrAddTsParam->tspecIdx = aggrQosReq->aggrInfo.tspecIdx;
980
981 for (i = 0; i < HAL_QOS_NUM_AC_MAX; i++) {
982 if (aggrQosReq->aggrInfo.tspecIdx & (1 << i)) {
983 tSirMacTspecIE *pTspec =
984 &aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
985 /* Since AddTS response was successful, check for the PSB flag
986 * and directional flag inside the TS Info field.
987 * An AC is trigger enabled AC if the PSB subfield is set to 1
988 * in the uplink direction.
989 * An AC is delivery enabled AC if the PSB subfield is set to 1
990 * in the downlink direction.
991 * An AC is trigger and delivery enabled AC if the PSB subfield
992 * is set to 1 in the bi-direction field.
993 */
994 if (pTspec->tsinfo.traffic.psb == 1) {
995 lim_set_tspec_uapsd_mask_per_session(pMac,
996 psessionEntry,
997 &pTspec->
998 tsinfo,
999 SET_UAPSD_MASK);
1000 } else {
1001 lim_set_tspec_uapsd_mask_per_session(pMac,
1002 psessionEntry,
1003 &pTspec->
1004 tsinfo,
1005 CLEAR_UAPSD_MASK);
1006 }
1007 /*
1008 * ADDTS success, so AC is now admitted.
1009 * We shall now use the default
1010 * EDCA parameters as advertised by AP and
1011 * send the updated EDCA params
1012 * to HAL.
1013 */
1014 ac = upToAc(pTspec->tsinfo.traffic.userPrio);
1015 if (pTspec->tsinfo.traffic.direction ==
1016 SIR_MAC_DIRECTION_UPLINK) {
1017 psessionEntry->
1018 gAcAdmitMask
1019 [SIR_MAC_DIRECTION_UPLINK] |=
1020 (1 << ac);
1021 } else if (pTspec->tsinfo.traffic.direction ==
1022 SIR_MAC_DIRECTION_DNLINK) {
1023 psessionEntry->
1024 gAcAdmitMask
1025 [SIR_MAC_DIRECTION_DNLINK] |=
1026 (1 << ac);
1027 } else if (pTspec->tsinfo.traffic.direction ==
1028 SIR_MAC_DIRECTION_BIDIR) {
1029 psessionEntry->
1030 gAcAdmitMask
1031 [SIR_MAC_DIRECTION_UPLINK] |=
1032 (1 << ac);
1033 psessionEntry->
1034 gAcAdmitMask
1035 [SIR_MAC_DIRECTION_DNLINK] |=
1036 (1 << ac);
1037 }
1038 lim_set_active_edca_params(pMac,
1039 psessionEntry->gLimEdcaParams,
1040 psessionEntry);
1041
1042 lim_send_edca_params(pMac,
1043 psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08001044 pSta->bssId, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045
1046 if (eSIR_SUCCESS !=
1047 lim_tspec_add(pMac, pSta->staAddr, pSta->assocId,
1048 pTspec, 0, &tspecInfo)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +05301049 pe_err("Adding entry in lim Tspec Table failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 pMac->lim.gLimAddtsSent = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301051 qdf_mem_free(pAggrAddTsParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 return eSIR_FAILURE;
1053 }
1054
1055 pAggrAddTsParam->tspec[i] =
1056 aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
1057 }
1058 }
1059
1060#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1061 if (!pMac->roam.configParam.isRoamOffloadEnabled ||
1062 (pMac->roam.configParam.isRoamOffloadEnabled &&
1063 !psessionEntry->is11Rconnection))
1064#endif
1065 {
1066 msg.type = WMA_AGGR_QOS_REQ;
1067 msg.bodyptr = pAggrAddTsParam;
1068 msg.bodyval = 0;
1069
1070 /* We need to defer any incoming messages until we get a
1071 * WMA_AGGR_QOS_RSP from HAL.
1072 */
1073 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1074 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msg.type));
1075
1076 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Nishank Aggarwal8b805bb2017-03-23 14:50:18 +05301077 pe_warn("wma_post_ctrl_msg() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301079 qdf_mem_free(pAggrAddTsParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 return eSIR_FAILURE;
1081 }
1082 }
1083#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1084 else {
1085 /* Implies it is a LFR3.0 based 11r connection
Jeff Johnson47d75242018-05-12 15:58:53 -07001086 * so donot send add ts request to firmware since it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 * already has the RIC IEs */
1088
1089 /* Send the Aggr QoS response to SME */
1090 lim_ft_send_aggr_qos_rsp(pMac, true, pAggrAddTsParam,
1091 psessionEntry->smeSessionId);
1092 if (pAggrAddTsParam != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301093 qdf_mem_free(pAggrAddTsParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 }
1095 }
1096#endif
1097
1098 return eSIR_SUCCESS;
1099}