Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved. |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 3 | * |
| 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 Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 21 | |
| 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 Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 28 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | * |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 30 | * 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 41 | #include "aniGlobal.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 42 | #include "wniCfgSta.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 43 | #include "sirCommon.h" |
| 44 | #include "sirDebug.h" |
| 45 | #include "utilsApi.h" |
| 46 | #include "cfgApi.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | #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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 55 | #define LIM_GET_NOISE_MAX_TRY 5 |
Sandeep Puligilla | a9eb9ad | 2014-05-27 14:42:50 +0530 | [diff] [blame^] | 56 | #define LIM_OPERATING_EXT_IDENTIFIER 201 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 57 | /** |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 77 | void |
| 78 | limExtractApCapability(tpAniSirGlobal pMac, tANI_U8 *pIE, tANI_U16 ieLen, |
| 79 | tANI_U8 *qosCap, tANI_U16 *propCap, tANI_U8 *uapsd, |
Madan Mohan Koyyalamudi | c6226de | 2012-09-18 16:33:31 -0700 | [diff] [blame] | 80 | tPowerdBm *localConstraint, |
| 81 | tpPESession psessionEntry |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 82 | ) |
| 83 | { |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 84 | tSirProbeRespBeacon *pBeaconStruct; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | #if !defined WLAN_FEATURE_VOWIFI |
| 86 | tANI_U32 localPowerConstraints = 0; |
| 87 | #endif |
Madan Mohan Koyyalamudi | 9e8ce1f | 2013-07-11 10:40:43 +0530 | [diff] [blame] | 88 | |
| 89 | pBeaconStruct = vos_mem_malloc(sizeof(tSirProbeRespBeacon)); |
| 90 | |
| 91 | if ( NULL == pBeaconStruct ) |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 92 | { |
Madan Mohan Koyyalamudi | 9e8ce1f | 2013-07-11 10:40:43 +0530 | [diff] [blame] | 93 | limLog(pMac, LOGE, FL("Unable to allocate memory in limExtractApCapability") ); |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 94 | return; |
| 95 | } |
| 96 | |
Madan Mohan Koyyalamudi | 9e8ce1f | 2013-07-11 10:40:43 +0530 | [diff] [blame] | 97 | vos_mem_set( (tANI_U8 *) pBeaconStruct, sizeof(tSirProbeRespBeacon), 0); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 98 | *qosCap = 0; |
| 99 | *propCap = 0; |
| 100 | *uapsd = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 101 | PELOG3(limLog( pMac, LOG3, |
Kiran Kumar Lokere | 531ca70 | 2013-04-01 13:24:23 -0700 | [diff] [blame] | 102 | FL("In limExtractApCapability: The IE's being received are:")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 103 | sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );) |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 104 | if (sirParseBeaconIE(pMac, pBeaconStruct, pIE, (tANI_U32)ieLen) == eSIR_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 105 | { |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 106 | if (pBeaconStruct->wmeInfoPresent || pBeaconStruct->wmeEdcaPresent) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 107 | LIM_BSS_CAPS_SET(WME, *qosCap); |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 108 | if (LIM_BSS_CAPS_GET(WME, *qosCap) && pBeaconStruct->wsmCapablePresent) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 109 | LIM_BSS_CAPS_SET(WSM, *qosCap); |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 110 | if (pBeaconStruct->propIEinfo.aniIndicator && |
| 111 | pBeaconStruct->propIEinfo.capabilityPresent) |
| 112 | *propCap = pBeaconStruct->propIEinfo.capability; |
| 113 | if (pBeaconStruct->HTCaps.present) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 114 | pMac->lim.htCapabilityPresentInBeacon = 1; |
| 115 | else |
| 116 | pMac->lim.htCapabilityPresentInBeacon = 0; |
| 117 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 118 | #ifdef WLAN_FEATURE_11AC |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 119 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED, |
Kiran Kumar Lokere | 531ca70 | 2013-04-01 13:24:23 -0700 | [diff] [blame] | 120 | "***beacon.VHTCaps.present*****=%d",pBeaconStruct->VHTCaps.present); |
Shailender Karmuchi | 08f87c2 | 2013-01-17 12:51:24 -0800 | [diff] [blame] | 121 | VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED, |
Kiran Kumar Lokere | 531ca70 | 2013-04-01 13:24:23 -0700 | [diff] [blame] | 122 | "***beacon.SU Beamformer Capable*****=%d",pBeaconStruct->VHTCaps.suBeamFormerCap); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 123 | |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 124 | if ( pBeaconStruct->VHTCaps.present && pBeaconStruct->VHTOperation.present) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 125 | { |
Madan Mohan Koyyalamudi | c6226de | 2012-09-18 16:33:31 -0700 | [diff] [blame] | 126 | psessionEntry->vhtCapabilityPresentInBeacon = 1; |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 127 | psessionEntry->apCenterChan = pBeaconStruct->VHTOperation.chanCenterFreqSeg1; |
| 128 | psessionEntry->apChanWidth = pBeaconStruct->VHTOperation.chanWidth; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 129 | } |
| 130 | else |
| 131 | { |
Madan Mohan Koyyalamudi | c6226de | 2012-09-18 16:33:31 -0700 | [diff] [blame] | 132 | psessionEntry->vhtCapabilityPresentInBeacon = 0; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 133 | } |
| 134 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 135 | // Extract the UAPSD flag from WMM Parameter element |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 136 | if (pBeaconStruct->wmeEdcaPresent) |
| 137 | *uapsd = pBeaconStruct->edcaParams.qosInfo.uapsd; |
Sandeep Puligilla | a9eb9ad | 2014-05-27 14:42:50 +0530 | [diff] [blame^] | 138 | |
| 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 Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 169 | #if defined FEATURE_WLAN_ESE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 170 | /* 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 Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 174 | if ( pBeaconStruct->eseTxPwr.present) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 175 | { |
Varun Reddy Yeturu | 5d5e2c6 | 2014-02-27 13:31:29 -0800 | [diff] [blame] | 176 | *localConstraint = pBeaconStruct->eseTxPwr.power_limit; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 177 | } |
| 178 | #endif |
Madan Mohan Koyyalamudi | 1903276 | 2012-10-21 12:42:11 -0700 | [diff] [blame] | 179 | if (pBeaconStruct->powerConstraintPresent) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 180 | { |
Sandeep Puligilla | a9eb9ad | 2014-05-27 14:42:50 +0530 | [diff] [blame^] | 181 | *localConstraint -= pBeaconStruct->localPowerConstraint.localPowerConstraints; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 182 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 183 | #if !defined WLAN_FEATURE_VOWIFI |
Sandeep Puligilla | a9eb9ad | 2014-05-27 14:42:50 +0530 | [diff] [blame^] | 184 | localPowerConstraints = (tANI_U32)pBeaconStruct->localPowerConstraint.localPowerConstraints; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 185 | if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, localPowerConstraints) != eSIR_SUCCESS) |
| 186 | { |
Kiran Kumar Lokere | 531ca70 | 2013-04-01 13:24:23 -0700 | [diff] [blame] | 187 | limLog(pMac, LOGP, FL("Could not update local power constraint to cfg.")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 188 | } |
| 189 | #endif |
Rajesh Babu Prathipati | 043149f | 2014-06-06 13:33:45 +0530 | [diff] [blame] | 190 | psessionEntry->countryInfoPresent = FALSE; /* Initializing before first use */ |
| 191 | if (pBeaconStruct->countryInfoPresent) |
| 192 | { |
| 193 | psessionEntry->countryInfoPresent = TRUE; |
| 194 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 195 | } |
Madan Mohan Koyyalamudi | 9e8ce1f | 2013-07-11 10:40:43 +0530 | [diff] [blame] | 196 | vos_mem_free(pBeaconStruct); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 197 | return; |
| 198 | } /****** end limExtractApCapability() ******/ |
| 199 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 200 | /** |
| 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 Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 214 | ePhyChanBondState limGetHTCBState(ePhyChanBondState aniCBMode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 215 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 216 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 241 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 242 | * 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 | */ |
| 261 | tStaRateMode limGetStaPeerType( tpAniSirGlobal pMac, |
| 262 | tpDphHashNode pStaDs, |
| 263 | tpPESession psessionEntry) |
| 264 | { |
| 265 | tStaRateMode staPeerType = eSTA_11b; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 266 | // 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 Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 276 | #ifdef WLAN_FEATURE_11AC |
| 277 | else if(pStaDs->mlmStaContext.vhtCapability) |
| 278 | staPeerType = eSTA_11ac; |
| 279 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 280 | 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 286 | return staPeerType; |
| 287 | } |
| 288 | |