blob: 80510e1a0449ec0bd89c8b6f097ef4f8de27384d [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002 * Copyright (c) 2012-2014 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"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "wniCfgSta.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 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700106 if (pBeaconStruct->wmeInfoPresent || pBeaconStruct->wmeEdcaPresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700107 LIM_BSS_CAPS_SET(WME, *qosCap);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700108 if (LIM_BSS_CAPS_GET(WME, *qosCap) && pBeaconStruct->wsmCapablePresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700109 LIM_BSS_CAPS_SET(WSM, *qosCap);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700110 if (pBeaconStruct->propIEinfo.aniIndicator &&
111 pBeaconStruct->propIEinfo.capabilityPresent)
112 *propCap = pBeaconStruct->propIEinfo.capability;
113 if (pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700114 pMac->lim.htCapabilityPresentInBeacon = 1;
115 else
116 pMac->lim.htCapabilityPresentInBeacon = 0;
117
Jeff Johnsone7245742012-09-05 17:12:55 -0700118#ifdef WLAN_FEATURE_11AC
Jeff Johnson32d95a32012-09-10 13:15:23 -0700119 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700120 "***beacon.VHTCaps.present*****=%d",pBeaconStruct->VHTCaps.present);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -0800121 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700122 "***beacon.SU Beamformer Capable*****=%d",pBeaconStruct->VHTCaps.suBeamFormerCap);
Jeff Johnsone7245742012-09-05 17:12:55 -0700123
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700124 if ( pBeaconStruct->VHTCaps.present && pBeaconStruct->VHTOperation.present)
Jeff Johnsone7245742012-09-05 17:12:55 -0700125 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700126 psessionEntry->vhtCapabilityPresentInBeacon = 1;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700127 psessionEntry->apCenterChan = pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
128 psessionEntry->apChanWidth = pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700129 }
130 else
131 {
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700132 psessionEntry->vhtCapabilityPresentInBeacon = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700133 }
134#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 // Extract the UAPSD flag from WMM Parameter element
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700136 if (pBeaconStruct->wmeEdcaPresent)
137 *uapsd = pBeaconStruct->edcaParams.qosInfo.uapsd;
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530138
139 /* Get MaxTxPwr from country IE if present.
140 If the channel number field has a positive integer value less
141 than 201, then it contains a positive integer value that indicates
142 the lowest channel number in the subband */
143
144 if (pBeaconStruct->countryInfoPresent &&
145 pBeaconStruct->countryInfoParam.channelTransmitPower[0].channelNumber < LIM_OPERATING_EXT_IDENTIFIER )
146 {
147 int i;
148 tANI_U8 firstChannel =0, numChannels =0;
149 tANI_U8 channel = psessionEntry->currentOperChannel;
150
151 for (i=0; i < pBeaconStruct->countryInfoParam.numIntervals; ++i)
152 {
153 if (i >= COUNTRY_INFO_MAX_CHANNEL)
154 break;
155
156 firstChannel = pBeaconStruct->countryInfoParam.channelTransmitPower[i].channelNumber;
157 numChannels = pBeaconStruct->countryInfoParam.channelTransmitPower[i].numChannel;
158
159 if ((channel >= firstChannel) &&
160 (channel < (firstChannel + numChannels)))
161 break;
162 }
163
164 if (i < pBeaconStruct->countryInfoParam.numIntervals && i < COUNTRY_INFO_MAX_CHANNEL)
165 {
166 *localConstraint = pBeaconStruct->countryInfoParam.channelTransmitPower[i].maxTransmitPower;
167 }
168 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800169#if defined FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700170 /* If there is Power Constraint Element specifically,
171 * adapt to it. Hence there is else condition check
172 * for this if statement.
173 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800174 if ( pBeaconStruct->eseTxPwr.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800176 *localConstraint = pBeaconStruct->eseTxPwr.power_limit;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 }
178#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700179 if (pBeaconStruct->powerConstraintPresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 {
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530181 *localConstraint -= pBeaconStruct->localPowerConstraint.localPowerConstraints;
Jeff Johnson295189b2012-06-20 16:38:30 -0700182 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700183#if !defined WLAN_FEATURE_VOWIFI
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +0530184 localPowerConstraints = (tANI_U32)pBeaconStruct->localPowerConstraint.localPowerConstraints;
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, localPowerConstraints) != eSIR_SUCCESS)
186 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700187 limLog(pMac, LOGP, FL("Could not update local power constraint to cfg."));
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 }
189#endif
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +0530190 psessionEntry->countryInfoPresent = FALSE; /* Initializing before first use */
191 if (pBeaconStruct->countryInfoPresent)
192 {
193 psessionEntry->countryInfoPresent = TRUE;
194 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530196 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 return;
198} /****** end limExtractApCapability() ******/
199
Jeff Johnson295189b2012-06-20 16:38:30 -0700200/**
201 * limGetHTCBState
202 *
203 *FUNCTION:
204 * This routing provides the translation of Airgo Enum to HT enum for determining
205 * secondary channel offset.
206 * Airgo Enum is required for backward compatibility purposes.
207 *
208 *
209 *NOTE:
210 *
211 * @param pMac - Pointer to Global MAC structure
212 * @return The corresponding HT enumeration
213 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700214ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode)
Jeff Johnson295189b2012-06-20 16:38:30 -0700215{
Jeff Johnsone7245742012-09-05 17:12:55 -0700216 switch ( aniCBMode )
217 {
218#ifdef WLAN_FEATURE_11AC
219 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
220 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
221 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
222#endif
223 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
224 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
225#ifdef WLAN_FEATURE_11AC
226 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
227 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
228 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
229#endif
230 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
231 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
232#ifdef WLAN_FEATURE_11AC
233 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
234 return PHY_SINGLE_CHANNEL_CENTERED;
235#endif
236 default :
237 return PHY_SINGLE_CHANNEL_CENTERED;
238 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700239}
240
Jeff Johnsone7245742012-09-05 17:12:55 -0700241 /*
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 * limGetStaPeerType
243 *
244 *FUNCTION:
245 * Based on a combination of the following -
246 * 1) tDphHashNode.aniPeer
247 * 2) tDphHashNode.propCapability
248 * this API determines if a given STA is an ANI peer or not
249 *
250 *LOGIC:
251 *
252 *ASSUMPTIONS:
253 *
254 *NOTE:
255 *
256 * @param pMac - Pointer to Global MAC structure
257 * @param pStaDs - Pointer to the tpDphHashNode of the STA
258 * under consideration
259 * @return tStaRateMode
260 */
261tStaRateMode limGetStaPeerType( tpAniSirGlobal pMac,
262 tpDphHashNode pStaDs,
263 tpPESession psessionEntry)
264{
265tStaRateMode staPeerType = eSTA_11b;
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 // Determine the peer-STA type
267 if( pStaDs->aniPeer )
268 {
269 if(PROP_CAPABILITY_GET( TAURUS, pStaDs->propCapability ))
270 staPeerType = eSTA_TAURUS;
271 else if( PROP_CAPABILITY_GET( TITAN, pStaDs->propCapability ))
272 staPeerType = eSTA_TITAN;
273 else
274 staPeerType = eSTA_POLARIS;
275 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700276#ifdef WLAN_FEATURE_11AC
277 else if(pStaDs->mlmStaContext.vhtCapability)
278 staPeerType = eSTA_11ac;
279#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 else if(pStaDs->mlmStaContext.htCapability)
281 staPeerType = eSTA_11n;
282 else if(pStaDs->erpEnabled)
283 staPeerType = eSTA_11bg;
284 else if(psessionEntry->limRFBand == SIR_BAND_5_GHZ)
285 staPeerType = eSTA_11a;
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 return staPeerType;
287}
288