blob: 2549bf55c835cc7f86618528d3f0f53aa024d176 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh74037df2017-07-20 11:08:56 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 *
Jeff Johnson295189b2012-06-20 16:38:30 -070030 * This file limPropExtsUtils.cc contains the utility functions
31 * to populate, parse proprietary extensions required to
32 * support ANI feature set.
33 *
34 * Author: Chandra Modumudi
35 * Date: 11/27/02
36 * History:-
37 * Date Modified by Modification Information
38 * --------------------------------------------------------------------
39 *
40 */
Jeff Johnson295189b2012-06-20 16:38:30 -070041#include "aniGlobal.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053042#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "sirCommon.h"
44#include "sirDebug.h"
45#include "utilsApi.h"
46#include "cfgApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070047#include "limApi.h"
48#include "limTypes.h"
49#include "limUtils.h"
50#include "limAssocUtils.h"
51#include "limPropExtsUtils.h"
52#include "limSerDesUtils.h"
53#include "limTrace.h"
54#include "limSession.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070055#define LIM_GET_NOISE_MAX_TRY 5
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +053056#define LIM_OPERATING_EXT_IDENTIFIER 201
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +053057
58/**
59 * limCheckOUI() - Check if the given OUI match in IE buffer
60 * @pMac: Pointer to Global MAC structure
61 * @pIE: Pointer to starting IE
62 * @ieLen: Length of all IEs
63 *
64 * Return: None
65 */
66static void limCheckOUI(tpAniSirGlobal pMac, tANI_U8 *pIE, tANI_U16 ieLen)
67{
68 tANI_U16 left = ieLen;
69 tANI_U8 *ptr = pIE;
70 tANI_U8 elem_id, elem_len, oui_len, i=0;
71
72 pMac->roam.configParam.agg_btc_sco_enabled = eANI_BOOLEAN_FALSE;
73
74 if (!ptr || ieLen == 0) {
75 limLog(pMac, LOGE, FL("Invalid IEs"));
76 return;
77 }
78 if (!pMac->roam.configParam.num_ba_buff_btc_sco)
79 return;
80
81 oui_len = 3;
82 while(i < oui_len && pMac->roam.configParam.agg_btc_sco_oui[i] == 0)
83 i+=1;
84 if (i == oui_len) {
85 /*
86 * If gEnableAggBTCScoOUI ini is not set, oui is set to all
87 * zeros and aggregation during SCO should be enabled for
88 * all APs.
89 */
90 pMac->roam.configParam.agg_btc_sco_enabled = eANI_BOOLEAN_TRUE;
91 return;
92 }
93
94 while (left >= 2) {
95 elem_id = ptr[0];
96 elem_len = ptr[1];
97 left -= 2;
98 if (elem_len > left) {
99 limLog(pMac, LOGE, FL("Invalid IEs eid: %d elem_len: %d left: %d"),
100 elem_id, elem_len, left);
101 return;
102 }
103 if (SIR_MAC_EID_VENDOR == elem_id) {
104 if (memcmp(&ptr[2], &pMac->roam.configParam.agg_btc_sco_oui,
105 oui_len) == 0) {
106 pMac->roam.configParam.agg_btc_sco_enabled = eANI_BOOLEAN_TRUE;
107 return;
108 }
109 }
110 left -= elem_len;
111 ptr += (elem_len + 2);
112 }
113}
114
Jeff Johnson295189b2012-06-20 16:38:30 -0700115/**
116 * limExtractApCapability()
117 *
118 *FUNCTION:
119 * This function is called to extract AP's HCF/WME/WSM capability
120 * from the IEs received from it in Beacon/Probe Response frames
121 *
122 *LOGIC:
123 *
124 *ASSUMPTIONS:
125 * NA
126 *
127 *NOTE:
128 *
129 * @param pMac Pointer to Global MAC structure
130 * @param pIE Pointer to starting IE in Beacon/Probe Response
131 * @param ieLen Length of all IEs combined
132 * @param qosCap Bits are set according to capabilities
133 * @return 0 - If AP does not assert HCF capability & 1 - otherwise
134 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700135void
136limExtractApCapability(tpAniSirGlobal pMac, tANI_U8 *pIE, tANI_U16 ieLen,
137 tANI_U8 *qosCap, tANI_U16 *propCap, tANI_U8 *uapsd,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700138 tPowerdBm *localConstraint,
139 tpPESession psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 )
141{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700142 tSirProbeRespBeacon *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -0700143#if !defined WLAN_FEATURE_VOWIFI
144 tANI_U32 localPowerConstraints = 0;
145#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530146
147 pBeaconStruct = vos_mem_malloc(sizeof(tSirProbeRespBeacon));
148
149 if ( NULL == pBeaconStruct )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700150 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530151 limLog(pMac, LOGE, FL("Unable to allocate memory in limExtractApCapability") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700152 return;
153 }
154
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530155 vos_mem_set( (tANI_U8 *) pBeaconStruct, sizeof(tSirProbeRespBeacon), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 *qosCap = 0;
157 *propCap = 0;
158 *uapsd = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700160 FL("In limExtractApCapability: The IE's being received are:"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700162 if (sirParseBeaconIE(pMac, pBeaconStruct, pIE, (tANI_U32)ieLen) == eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 {
Pradeep Reddy POTTETIa1314a82015-07-16 15:34:24 +0530164 if (pBeaconStruct->wmeInfoPresent || pBeaconStruct->wmeEdcaPresent
165 || pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 LIM_BSS_CAPS_SET(WME, *qosCap);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700167 if (LIM_BSS_CAPS_GET(WME, *qosCap) && pBeaconStruct->wsmCapablePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700168 LIM_BSS_CAPS_SET(WSM, *qosCap);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700169 if (pBeaconStruct->propIEinfo.aniIndicator &&
170 pBeaconStruct->propIEinfo.capabilityPresent)
171 *propCap = pBeaconStruct->propIEinfo.capability;
172 if (pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 pMac->lim.htCapabilityPresentInBeacon = 1;
174 else
175 pMac->lim.htCapabilityPresentInBeacon = 0;
176
Jeff Johnsone7245742012-09-05 17:12:55 -0700177#ifdef WLAN_FEATURE_11AC
Jeff Johnson32d95a32012-09-10 13:15:23 -0700178 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530179 "***beacon.VHTCaps.present*****=%d BSS_VHT_CAPABLE:%d",
180 pBeaconStruct->VHTCaps.present,
181 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -0800182 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700183 "***beacon.SU Beamformer Capable*****=%d",pBeaconStruct->VHTCaps.suBeamFormerCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700184
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530185 if (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps)
186 && pBeaconStruct->VHTOperation.present)
Jeff Johnsone7245742012-09-05 17:12:55 -0700187 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700188 psessionEntry->vhtCapabilityPresentInBeacon = 1;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700189 psessionEntry->apCenterChan = pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
190 psessionEntry->apChanWidth = pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700191 }
192 else
193 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700194 psessionEntry->vhtCapabilityPresentInBeacon = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700195 }
196#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 // Extract the UAPSD flag from WMM Parameter element
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700198 if (pBeaconStruct->wmeEdcaPresent)
199 *uapsd = pBeaconStruct->edcaParams.qosInfo.uapsd;
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530200
201 /* Get MaxTxPwr from country IE if present.
202 If the channel number field has a positive integer value less
203 than 201, then it contains a positive integer value that indicates
204 the lowest channel number in the subband */
205
206 if (pBeaconStruct->countryInfoPresent &&
207 pBeaconStruct->countryInfoParam.channelTransmitPower[0].channelNumber < LIM_OPERATING_EXT_IDENTIFIER )
208 {
209 int i;
210 tANI_U8 firstChannel =0, numChannels =0;
211 tANI_U8 channel = psessionEntry->currentOperChannel;
212
213 for (i=0; i < pBeaconStruct->countryInfoParam.numIntervals; ++i)
214 {
215 if (i >= COUNTRY_INFO_MAX_CHANNEL)
216 break;
217
218 firstChannel = pBeaconStruct->countryInfoParam.channelTransmitPower[i].channelNumber;
219 numChannels = pBeaconStruct->countryInfoParam.channelTransmitPower[i].numChannel;
220
221 if ((channel >= firstChannel) &&
222 (channel < (firstChannel + numChannels)))
223 break;
224 }
225
226 if (i < pBeaconStruct->countryInfoParam.numIntervals && i < COUNTRY_INFO_MAX_CHANNEL)
227 {
228 *localConstraint = pBeaconStruct->countryInfoParam.channelTransmitPower[i].maxTransmitPower;
229 }
230 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800231#if defined FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 /* If there is Power Constraint Element specifically,
233 * adapt to it. Hence there is else condition check
234 * for this if statement.
235 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800236 if ( pBeaconStruct->eseTxPwr.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700237 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800238 *localConstraint = pBeaconStruct->eseTxPwr.power_limit;
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 }
240#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700241 if (pBeaconStruct->powerConstraintPresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 {
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530243 *localConstraint -= pBeaconStruct->localPowerConstraint.localPowerConstraints;
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700245#if !defined WLAN_FEATURE_VOWIFI
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530246 localPowerConstraints = (tANI_U32)pBeaconStruct->localPowerConstraint.localPowerConstraints;
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, localPowerConstraints) != eSIR_SUCCESS)
248 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700249 limLog(pMac, LOGP, FL("Could not update local power constraint to cfg."));
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 }
251#endif
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +0530252 psessionEntry->countryInfoPresent = FALSE; /* Initializing before first use */
253 if (pBeaconStruct->countryInfoPresent)
254 {
255 psessionEntry->countryInfoPresent = TRUE;
256 }
Hu Wang5193b572016-08-11 10:04:47 +0800257 /* Save the Extended caps from AP in probe resp or beacon */
Agrawal Ashish5ac89da2015-10-26 19:08:47 +0530258 if (pBeaconStruct->ExtCap.present)
259 {
Hu Wang5193b572016-08-11 10:04:47 +0800260 vos_mem_copy(&psessionEntry->ExtCap, &pBeaconStruct->ExtCap, sizeof(tDot11fIEExtCap));
Agrawal Ashish5ac89da2015-10-26 19:08:47 +0530261 }
262
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 }
Abhishek Singh74037df2017-07-20 11:08:56 +0530264
Yeshwanth Sriram Guntuka8d9b29c2017-12-12 15:44:57 +0530265 limCheckOUI(pMac, pIE, ieLen);
Abhishek Singh74037df2017-07-20 11:08:56 +0530266 /* Update HS 2.0 Information Element */
267 sir_copy_hs20_ie(&psessionEntry->hs20vendor_ie,
268 &pBeaconStruct->hs20vendor_ie);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530269 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 return;
271} /****** end limExtractApCapability() ******/
272
Jeff Johnson295189b2012-06-20 16:38:30 -0700273/**
274 * limGetHTCBState
275 *
276 *FUNCTION:
277 * This routing provides the translation of Airgo Enum to HT enum for determining
278 * secondary channel offset.
279 * Airgo Enum is required for backward compatibility purposes.
280 *
281 *
282 *NOTE:
283 *
284 * @param pMac - Pointer to Global MAC structure
285 * @return The corresponding HT enumeration
286 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700287ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode)
Jeff Johnson295189b2012-06-20 16:38:30 -0700288{
Jeff Johnsone7245742012-09-05 17:12:55 -0700289 switch ( aniCBMode )
290 {
291#ifdef WLAN_FEATURE_11AC
292 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
293 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
294 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
295#endif
296 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
297 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
298#ifdef WLAN_FEATURE_11AC
299 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
300 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
301 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
302#endif
303 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
304 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
305#ifdef WLAN_FEATURE_11AC
306 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
307 return PHY_SINGLE_CHANNEL_CENTERED;
308#endif
309 default :
310 return PHY_SINGLE_CHANNEL_CENTERED;
311 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700312}
313
Jeff Johnsone7245742012-09-05 17:12:55 -0700314 /*
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 * limGetStaPeerType
316 *
317 *FUNCTION:
318 * Based on a combination of the following -
319 * 1) tDphHashNode.aniPeer
320 * 2) tDphHashNode.propCapability
321 * this API determines if a given STA is an ANI peer or not
322 *
323 *LOGIC:
324 *
325 *ASSUMPTIONS:
326 *
327 *NOTE:
328 *
329 * @param pMac - Pointer to Global MAC structure
330 * @param pStaDs - Pointer to the tpDphHashNode of the STA
331 * under consideration
332 * @return tStaRateMode
333 */
334tStaRateMode limGetStaPeerType( tpAniSirGlobal pMac,
335 tpDphHashNode pStaDs,
336 tpPESession psessionEntry)
337{
338tStaRateMode staPeerType = eSTA_11b;
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 // Determine the peer-STA type
340 if( pStaDs->aniPeer )
341 {
342 if(PROP_CAPABILITY_GET( TAURUS, pStaDs->propCapability ))
343 staPeerType = eSTA_TAURUS;
344 else if( PROP_CAPABILITY_GET( TITAN, pStaDs->propCapability ))
345 staPeerType = eSTA_TITAN;
346 else
347 staPeerType = eSTA_POLARIS;
348 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700349#ifdef WLAN_FEATURE_11AC
350 else if(pStaDs->mlmStaContext.vhtCapability)
351 staPeerType = eSTA_11ac;
352#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 else if(pStaDs->mlmStaContext.htCapability)
354 staPeerType = eSTA_11n;
355 else if(pStaDs->erpEnabled)
356 staPeerType = eSTA_11bg;
357 else if(psessionEntry->limRFBand == SIR_BAND_5_GHZ)
358 staPeerType = eSTA_11a;
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 return staPeerType;
360}
361