blob: 1345a1158e40aa5e639af67c73a95c4a95b7225d [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Satyanarayana Dash6f438272015-03-03 18:01:06 +05302 * Copyright (c) 2012-2015 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
Jeff Johnson295189b2012-06-20 16:38:30 -070057/**
58 * limExtractApCapability()
59 *
60 *FUNCTION:
61 * This function is called to extract AP's HCF/WME/WSM capability
62 * from the IEs received from it in Beacon/Probe Response frames
63 *
64 *LOGIC:
65 *
66 *ASSUMPTIONS:
67 * NA
68 *
69 *NOTE:
70 *
71 * @param pMac Pointer to Global MAC structure
72 * @param pIE Pointer to starting IE in Beacon/Probe Response
73 * @param ieLen Length of all IEs combined
74 * @param qosCap Bits are set according to capabilities
75 * @return 0 - If AP does not assert HCF capability & 1 - otherwise
76 */
Jeff Johnson295189b2012-06-20 16:38:30 -070077void
78limExtractApCapability(tpAniSirGlobal pMac, tANI_U8 *pIE, tANI_U16 ieLen,
79 tANI_U8 *qosCap, tANI_U16 *propCap, tANI_U8 *uapsd,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070080 tPowerdBm *localConstraint,
81 tpPESession psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -070082 )
83{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -070084 tSirProbeRespBeacon *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -070085#if !defined WLAN_FEATURE_VOWIFI
86 tANI_U32 localPowerConstraints = 0;
87#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +053088
89 pBeaconStruct = vos_mem_malloc(sizeof(tSirProbeRespBeacon));
90
91 if ( NULL == pBeaconStruct )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -070092 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +053093 limLog(pMac, LOGE, FL("Unable to allocate memory in limExtractApCapability") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -070094 return;
95 }
96
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +053097 vos_mem_set( (tANI_U8 *) pBeaconStruct, sizeof(tSirProbeRespBeacon), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070098 *qosCap = 0;
99 *propCap = 0;
100 *uapsd = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700101 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700102 FL("In limExtractApCapability: The IE's being received are:"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700103 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700104 if (sirParseBeaconIE(pMac, pBeaconStruct, pIE, (tANI_U32)ieLen) == eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700105 {
Pradeep Reddy POTTETIa1314a82015-07-16 15:34:24 +0530106 if (pBeaconStruct->wmeInfoPresent || pBeaconStruct->wmeEdcaPresent
107 || pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700108 LIM_BSS_CAPS_SET(WME, *qosCap);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700109 if (LIM_BSS_CAPS_GET(WME, *qosCap) && pBeaconStruct->wsmCapablePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700110 LIM_BSS_CAPS_SET(WSM, *qosCap);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700111 if (pBeaconStruct->propIEinfo.aniIndicator &&
112 pBeaconStruct->propIEinfo.capabilityPresent)
113 *propCap = pBeaconStruct->propIEinfo.capability;
114 if (pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700115 pMac->lim.htCapabilityPresentInBeacon = 1;
116 else
117 pMac->lim.htCapabilityPresentInBeacon = 0;
118
Jeff Johnsone7245742012-09-05 17:12:55 -0700119#ifdef WLAN_FEATURE_11AC
Jeff Johnson32d95a32012-09-10 13:15:23 -0700120 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530121 "***beacon.VHTCaps.present*****=%d BSS_VHT_CAPABLE:%d",
122 pBeaconStruct->VHTCaps.present,
123 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -0800124 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700125 "***beacon.SU Beamformer Capable*****=%d",pBeaconStruct->VHTCaps.suBeamFormerCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700126
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530127 if (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps)
128 && pBeaconStruct->VHTOperation.present)
Jeff Johnsone7245742012-09-05 17:12:55 -0700129 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700130 psessionEntry->vhtCapabilityPresentInBeacon = 1;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700131 psessionEntry->apCenterChan = pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
132 psessionEntry->apChanWidth = pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700133 }
134 else
135 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700136 psessionEntry->vhtCapabilityPresentInBeacon = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700137 }
138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 // Extract the UAPSD flag from WMM Parameter element
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700140 if (pBeaconStruct->wmeEdcaPresent)
141 *uapsd = pBeaconStruct->edcaParams.qosInfo.uapsd;
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530142
143 /* Get MaxTxPwr from country IE if present.
144 If the channel number field has a positive integer value less
145 than 201, then it contains a positive integer value that indicates
146 the lowest channel number in the subband */
147
148 if (pBeaconStruct->countryInfoPresent &&
149 pBeaconStruct->countryInfoParam.channelTransmitPower[0].channelNumber < LIM_OPERATING_EXT_IDENTIFIER )
150 {
151 int i;
152 tANI_U8 firstChannel =0, numChannels =0;
153 tANI_U8 channel = psessionEntry->currentOperChannel;
154
155 for (i=0; i < pBeaconStruct->countryInfoParam.numIntervals; ++i)
156 {
157 if (i >= COUNTRY_INFO_MAX_CHANNEL)
158 break;
159
160 firstChannel = pBeaconStruct->countryInfoParam.channelTransmitPower[i].channelNumber;
161 numChannels = pBeaconStruct->countryInfoParam.channelTransmitPower[i].numChannel;
162
163 if ((channel >= firstChannel) &&
164 (channel < (firstChannel + numChannels)))
165 break;
166 }
167
168 if (i < pBeaconStruct->countryInfoParam.numIntervals && i < COUNTRY_INFO_MAX_CHANNEL)
169 {
170 *localConstraint = pBeaconStruct->countryInfoParam.channelTransmitPower[i].maxTransmitPower;
171 }
172 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800173#if defined FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 /* If there is Power Constraint Element specifically,
175 * adapt to it. Hence there is else condition check
176 * for this if statement.
177 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178 if ( pBeaconStruct->eseTxPwr.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700179 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800180 *localConstraint = pBeaconStruct->eseTxPwr.power_limit;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181 }
182#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700183 if (pBeaconStruct->powerConstraintPresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 {
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530185 *localConstraint -= pBeaconStruct->localPowerConstraint.localPowerConstraints;
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700187#if !defined WLAN_FEATURE_VOWIFI
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530188 localPowerConstraints = (tANI_U32)pBeaconStruct->localPowerConstraint.localPowerConstraints;
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, localPowerConstraints) != eSIR_SUCCESS)
190 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700191 limLog(pMac, LOGP, FL("Could not update local power constraint to cfg."));
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 }
193#endif
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +0530194 psessionEntry->countryInfoPresent = FALSE; /* Initializing before first use */
195 if (pBeaconStruct->countryInfoPresent)
196 {
197 psessionEntry->countryInfoPresent = TRUE;
198 }
Agrawal Ashish5ac89da2015-10-26 19:08:47 +0530199 /* Check if Extended caps are present in probe resp or not */
200 if (pBeaconStruct->ExtCap.present)
201 {
202 psessionEntry->is_ext_caps_present = TRUE;
203 }
204
Jeff Johnson295189b2012-06-20 16:38:30 -0700205 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530206 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 return;
208} /****** end limExtractApCapability() ******/
209
Jeff Johnson295189b2012-06-20 16:38:30 -0700210/**
211 * limGetHTCBState
212 *
213 *FUNCTION:
214 * This routing provides the translation of Airgo Enum to HT enum for determining
215 * secondary channel offset.
216 * Airgo Enum is required for backward compatibility purposes.
217 *
218 *
219 *NOTE:
220 *
221 * @param pMac - Pointer to Global MAC structure
222 * @return The corresponding HT enumeration
223 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700224ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode)
Jeff Johnson295189b2012-06-20 16:38:30 -0700225{
Jeff Johnsone7245742012-09-05 17:12:55 -0700226 switch ( aniCBMode )
227 {
228#ifdef WLAN_FEATURE_11AC
229 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
230 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
231 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
232#endif
233 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
234 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
235#ifdef WLAN_FEATURE_11AC
236 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
237 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
238 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
239#endif
240 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
241 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
242#ifdef WLAN_FEATURE_11AC
243 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
244 return PHY_SINGLE_CHANNEL_CENTERED;
245#endif
246 default :
247 return PHY_SINGLE_CHANNEL_CENTERED;
248 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700249}
250
Jeff Johnsone7245742012-09-05 17:12:55 -0700251 /*
Jeff Johnson295189b2012-06-20 16:38:30 -0700252 * limGetStaPeerType
253 *
254 *FUNCTION:
255 * Based on a combination of the following -
256 * 1) tDphHashNode.aniPeer
257 * 2) tDphHashNode.propCapability
258 * this API determines if a given STA is an ANI peer or not
259 *
260 *LOGIC:
261 *
262 *ASSUMPTIONS:
263 *
264 *NOTE:
265 *
266 * @param pMac - Pointer to Global MAC structure
267 * @param pStaDs - Pointer to the tpDphHashNode of the STA
268 * under consideration
269 * @return tStaRateMode
270 */
271tStaRateMode limGetStaPeerType( tpAniSirGlobal pMac,
272 tpDphHashNode pStaDs,
273 tpPESession psessionEntry)
274{
275tStaRateMode staPeerType = eSTA_11b;
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 // Determine the peer-STA type
277 if( pStaDs->aniPeer )
278 {
279 if(PROP_CAPABILITY_GET( TAURUS, pStaDs->propCapability ))
280 staPeerType = eSTA_TAURUS;
281 else if( PROP_CAPABILITY_GET( TITAN, pStaDs->propCapability ))
282 staPeerType = eSTA_TITAN;
283 else
284 staPeerType = eSTA_POLARIS;
285 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700286#ifdef WLAN_FEATURE_11AC
287 else if(pStaDs->mlmStaContext.vhtCapability)
288 staPeerType = eSTA_11ac;
289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 else if(pStaDs->mlmStaContext.htCapability)
291 staPeerType = eSTA_11n;
292 else if(pStaDs->erpEnabled)
293 staPeerType = eSTA_11bg;
294 else if(psessionEntry->limRFBand == SIR_BAND_5_GHZ)
295 staPeerType = eSTA_11a;
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 return staPeerType;
297}
298