Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Yeshwanth Sriram Guntuka | ed0d3d0 | 2018-02-23 16:10:46 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2014, 2016-2018 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 | |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 22 | /* |
Kiet Lam | 842dad0 | 2014-02-18 18:44:02 -0800 | [diff] [blame] | 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 | |
| 28 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 29 | * This file limScanResultUtils.cc contains the utility functions |
| 30 | * LIM uses for maintaining and accessing scan results on STA. |
| 31 | * Author: Chandra Modumudi |
| 32 | * Date: 02/13/02 |
| 33 | * History:- |
| 34 | * Date Modified by Modification Information |
| 35 | * -------------------------------------------------------------------- |
| 36 | */ |
| 37 | |
| 38 | #include "limTypes.h" |
| 39 | #include "limUtils.h" |
| 40 | #include "limSerDesUtils.h" |
| 41 | #include "limApi.h" |
| 42 | #include "limSession.h" |
| 43 | #if defined WLAN_FEATURE_VOWIFI |
| 44 | #include "rrmApi.h" |
| 45 | #endif |
Abhishek Singh | e3fa11f | 2014-05-13 11:11:10 +0530 | [diff] [blame] | 46 | #include "vos_utils.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * limDeactiveMinChannelTimerDuringScan() |
| 50 | * |
| 51 | *FUNCTION: |
| 52 | * This function is called during scan upon receiving |
| 53 | * Beacon/Probe Response frame to deactivate MIN channel |
| 54 | * timer if running. |
| 55 | * |
| 56 | * This function should be called only when pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE |
| 57 | * |
| 58 | *LOGIC: |
| 59 | * |
| 60 | *ASSUMPTIONS: |
| 61 | * NA |
| 62 | * |
| 63 | *NOTE: |
| 64 | * NA |
| 65 | * |
| 66 | * @param pMac - Pointer to Global MAC structure |
| 67 | * |
| 68 | * @return eSIR_SUCCESS in case of success |
| 69 | */ |
| 70 | |
| 71 | tANI_U32 |
| 72 | limDeactivateMinChannelTimerDuringScan(tpAniSirGlobal pMac) |
| 73 | { |
Abhishek Singh | 01a1976 | 2015-09-03 11:07:19 +0530 | [diff] [blame] | 74 | if ((VOS_TRUE == |
| 75 | tx_timer_running(&pMac->lim.limTimers.gLimMinChannelTimer)) && |
| 76 | (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) && |
| 77 | (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 78 | { |
| 79 | /** |
Abhishek Singh | 01a1976 | 2015-09-03 11:07:19 +0530 | [diff] [blame] | 80 | * Beacon/Probe Response is received during active scanning. |
| 81 | * Deactivate MIN channel timer if running. |
| 82 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 83 | limDeactivateAndChangeTimer(pMac,eLIM_MIN_CHANNEL_TIMER); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 84 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 85 | } |
| 86 | return eSIR_SUCCESS; |
| 87 | } /*** end limDeactivateMinChannelTimerDuringScan() ***/ |
| 88 | |
| 89 | |
| 90 | |
| 91 | /** |
| 92 | * limCollectBssDescription() |
| 93 | * |
| 94 | *FUNCTION: |
| 95 | * This function is called during scan upon receiving |
| 96 | * Beacon/Probe Response frame to check if the received |
| 97 | * frame matches scan criteria, collect BSS description |
| 98 | * and add it to cached scan results. |
| 99 | * |
| 100 | *LOGIC: |
| 101 | * |
| 102 | *ASSUMPTIONS: |
| 103 | * NA |
| 104 | * |
| 105 | *NOTE: |
| 106 | * NA |
| 107 | * |
| 108 | * @param pMac - Pointer to Global MAC structure |
| 109 | * @param pBPR - Pointer to parsed Beacon/Probe Response structure |
| 110 | * @param pRxPacketInfo - Pointer to Received frame's BD |
| 111 | * ---------if defined WLAN_FEATURE_VOWIFI------ |
| 112 | * @param fScanning - flag to indicate if it is during scan. |
| 113 | * --------------------------------------------- |
| 114 | * |
| 115 | * @return None |
| 116 | */ |
| 117 | #if defined WLAN_FEATURE_VOWIFI |
Ganesh Kondabattini | 62feb16 | 2016-01-14 17:41:05 +0530 | [diff] [blame] | 118 | void |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 119 | limCollectBssDescription(tpAniSirGlobal pMac, |
| 120 | tSirBssDescription *pBssDescr, |
| 121 | tpSirProbeRespBeacon pBPR, |
| 122 | tANI_U8 *pRxPacketInfo, |
| 123 | tANI_U8 fScanning) |
| 124 | #else |
Ganesh Kondabattini | 62feb16 | 2016-01-14 17:41:05 +0530 | [diff] [blame] | 125 | void |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 126 | limCollectBssDescription(tpAniSirGlobal pMac, |
| 127 | tSirBssDescription *pBssDescr, |
| 128 | tpSirProbeRespBeacon pBPR, |
| 129 | tANI_U8 *pRxPacketInfo) |
| 130 | #endif |
| 131 | { |
| 132 | tANI_U8 *pBody; |
| 133 | tANI_U32 ieLen = 0; |
| 134 | tpSirMacMgmtHdr pHdr; |
| 135 | tANI_U8 channelNum; |
| 136 | tANI_U8 rxChannel; |
Kiran Kumar Lokere | 79540f9 | 2013-04-25 17:32:16 -0700 | [diff] [blame] | 137 | tANI_U8 rfBand = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 138 | |
| 139 | pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo); |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 140 | VOS_ASSERT(WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) >= SIR_MAC_B_PR_SSID_OFFSET); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 141 | ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) - SIR_MAC_B_PR_SSID_OFFSET; |
| 142 | rxChannel = WDA_GET_RX_CH(pRxPacketInfo); |
| 143 | pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo); |
Kiran Kumar Lokere | 79540f9 | 2013-04-25 17:32:16 -0700 | [diff] [blame] | 144 | rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 145 | |
| 146 | |
| 147 | /** |
| 148 | * Length of BSS desription is without length of |
| 149 | * length itself and length of pointer |
kjli | e157ed0 | 2016-07-29 11:16:09 +0800 | [diff] [blame] | 150 | * that holds ieFields |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 151 | */ |
| 152 | pBssDescr->length = (tANI_U16)( |
kjli | e157ed0 | 2016-07-29 11:16:09 +0800 | [diff] [blame] | 153 | ((uintptr_t)OFFSET_OF(tSirBssDescription, ieFields)) - |
| 154 | sizeof(pBssDescr->length) + ieLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 155 | |
| 156 | // Copy BSS Id |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 157 | vos_mem_copy((tANI_U8 *) &pBssDescr->bssId, |
| 158 | (tANI_U8 *) pHdr->bssId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 159 | sizeof(tSirMacAddr)); |
| 160 | |
| 161 | // Copy Timestamp, Beacon Interval and Capability Info |
| 162 | pBssDescr->scanSysTimeMsec = vos_timer_get_system_time(); |
| 163 | |
| 164 | pBssDescr->timeStamp[0] = pBPR->timeStamp[0]; |
| 165 | pBssDescr->timeStamp[1] = pBPR->timeStamp[1]; |
| 166 | pBssDescr->beaconInterval = pBPR->beaconInterval; |
| 167 | pBssDescr->capabilityInfo = limGetU16((tANI_U8 *) &pBPR->capabilityInfo); |
| 168 | |
Kapil Gupta | 04ab199 | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 169 | pBssDescr->HTCapsPresent = 0; |
| 170 | pBssDescr->chanWidth = eHT_CHANNEL_WIDTH_20MHZ; |
| 171 | pBssDescr->wmeInfoPresent = 0; |
| 172 | pBssDescr->vhtCapsPresent = 0; |
| 173 | pBssDescr->beacomformingCapable = 0; |
| 174 | /* HT capability */ |
| 175 | if (pBPR->HTCaps.present) { |
| 176 | pBssDescr->HTCapsPresent = 1; |
| 177 | if (pBPR->HTCaps.supportedChannelWidthSet) |
| 178 | pBssDescr->chanWidth = eHT_CHANNEL_WIDTH_40MHZ; |
| 179 | } |
| 180 | if (pBPR->wmeEdcaPresent) |
| 181 | pBssDescr->wmeInfoPresent = 1; |
| 182 | |
| 183 | #ifdef WLAN_FEATURE_11AC |
| 184 | /* VHT Parameters */ |
| 185 | if (pBPR->VHTCaps.present) { |
| 186 | pBssDescr->vhtCapsPresent = 1; |
| 187 | if (pBPR->VHTCaps.muBeamformerCap) |
| 188 | pBssDescr->beacomformingCapable = 1; |
| 189 | } |
| 190 | if (pBPR->VHTOperation.present) |
| 191 | if (pBPR->VHTOperation.chanWidth == 1) |
| 192 | pBssDescr->chanWidth = eHT_CHANNEL_WIDTH_80MHZ; |
| 193 | #endif |
| 194 | if(!pBssDescr->beaconInterval ) |
AnjaneeDevi Kapparapu | 4b04391 | 2014-02-18 13:22:35 +0530 | [diff] [blame] | 195 | { |
| 196 | limLog(pMac, LOGW, |
| 197 | FL("Beacon Interval is ZERO, making it to default 100 " |
| 198 | MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->bssId)); |
| 199 | pBssDescr->beaconInterval= 100; |
| 200 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 201 | /* |
| 202 | * There is a narrow window after Channel Switch msg is sent to HAL and before the AGC is shut |
| 203 | * down and beacons/Probe Rsps can trickle in and we may report the incorrect channel in 5Ghz |
| 204 | * band, so not relying on the 'last Scanned Channel' stored in LIM. |
| 205 | * Instead use the value returned by RXP in BD. This the the same value which HAL programs into |
| 206 | * RXP before every channel switch. |
| 207 | * Right now there is a problem in 5Ghz, where we are receiving beacons from a channel different from |
| 208 | * the currently scanned channel. so incorrect channel is reported to CSR and association does not happen. |
| 209 | * So for now we keep on looking for the channel info in the beacon (DSParamSet IE OR HT Info IE), and only if it |
| 210 | * is not present in the beacon, we go for the channel info present in RXP. |
| 211 | * This fix will work for 5Ghz 11n devices, but for 11a devices, we have to rely on RXP routing flag to get the correct channel. |
| 212 | * So The problem of incorrect channel reporting in 5Ghz will still remain for 11a devices. |
| 213 | */ |
| 214 | pBssDescr->channelId = limGetChannelFromBeacon(pMac, pBPR); |
| 215 | |
| 216 | if (pBssDescr->channelId == 0) |
Kiran Kumar Lokere | 79540f9 | 2013-04-25 17:32:16 -0700 | [diff] [blame] | 217 | { |
| 218 | /* If the channel Id is not retrieved from Beacon, extract the channel from BD */ |
| 219 | /* Unmapped the channel.This We have to do since we have done mapping in the hal to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 220 | overcome the limitation of RXBD of not able to accomodate the bigger channel number.*/ |
Kiran Kumar Lokere | 79540f9 | 2013-04-25 17:32:16 -0700 | [diff] [blame] | 221 | if ((!rfBand) || IS_5G_BAND(rfBand)) |
| 222 | { |
| 223 | rxChannel = limUnmapChannel(rxChannel); |
| 224 | } |
| 225 | if (!rxChannel) |
| 226 | { |
| 227 | rxChannel = pMac->lim.gLimCurrentScanChannelId; |
| 228 | } |
| 229 | pBssDescr->channelId = rxChannel; |
| 230 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 231 | |
Gopichand Nakkala | d492d20 | 2013-05-10 02:50:47 +0530 | [diff] [blame] | 232 | pBssDescr->channelIdSelf = pBssDescr->channelId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 233 | //set the network type in bss description |
| 234 | channelNum = pBssDescr->channelId; |
| 235 | pBssDescr->nwType = limGetNwType(pMac, channelNum, SIR_MAC_MGMT_FRAME, pBPR); |
| 236 | |
| 237 | pBssDescr->aniIndicator = pBPR->propIEinfo.aniIndicator; |
| 238 | |
| 239 | // Copy RSSI & SINR from BD |
| 240 | |
| 241 | PELOG4(limLog(pMac, LOG4, "***********BSS Description for BSSID:*********** "); |
| 242 | sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pBssDescr->bssId, 6 ); |
| 243 | sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG4, (tANI_U8*)pRxPacketInfo, 36 );) |
| 244 | |
| 245 | pBssDescr->rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo); |
| 246 | |
| 247 | //SINR no longer reported by HW |
| 248 | pBssDescr->sinr = 0; |
| 249 | |
Deepthi Gowri | 2f43513 | 2016-05-18 19:30:17 +0530 | [diff] [blame] | 250 | pBssDescr->nReceivedTime = vos_timer_get_system_time(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 251 | |
| 252 | #if defined WLAN_FEATURE_VOWIFI |
| 253 | if( fScanning ) |
| 254 | { |
| 255 | rrmGetStartTSF( pMac, pBssDescr->startTSF ); |
| 256 | pBssDescr->parentTSF = WDA_GET_RX_TIMESTAMP(pRxPacketInfo); |
| 257 | } |
| 258 | #endif |
| 259 | |
| 260 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 261 | // MobilityDomain |
| 262 | pBssDescr->mdie[0] = 0; |
| 263 | pBssDescr->mdie[1] = 0; |
| 264 | pBssDescr->mdie[2] = 0; |
| 265 | pBssDescr->mdiePresent = FALSE; |
| 266 | // If mdie is present in the probe resp we |
| 267 | // fill it in the bss description |
| 268 | if( pBPR->mdiePresent) |
| 269 | { |
| 270 | pBssDescr->mdiePresent = TRUE; |
| 271 | pBssDescr->mdie[0] = pBPR->mdie[0]; |
| 272 | pBssDescr->mdie[1] = pBPR->mdie[1]; |
| 273 | pBssDescr->mdie[2] = pBPR->mdie[2]; |
| 274 | } |
| 275 | #endif |
| 276 | |
Kapil Gupta | 04ab199 | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 277 | #if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_ROAM_SCAN_OFFLOAD) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 278 | pBssDescr->QBSSLoad_present = FALSE; |
| 279 | pBssDescr->QBSSLoad_avail = 0; |
| 280 | if( pBPR->QBSSLoad.present) |
| 281 | { |
| 282 | pBssDescr->QBSSLoad_present = TRUE; |
| 283 | pBssDescr->QBSSLoad_avail = pBPR->QBSSLoad.avail; |
Kapil Gupta | 04ab199 | 2016-06-26 13:36:51 +0530 | [diff] [blame] | 284 | pBssDescr->QBSS_ChanLoad = pBPR->QBSSLoad.chautil; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 285 | } |
| 286 | #endif |
| 287 | // Copy IE fields |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 288 | vos_mem_copy((tANI_U8 *) &pBssDescr->ieFields, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 289 | pBody + SIR_MAC_B_PR_SSID_OFFSET, |
| 290 | ieLen); |
| 291 | |
| 292 | //sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGW, (tANI_U8 *) pBssDescr, pBssDescr->length + 2 ); |
| 293 | limLog( pMac, LOG3, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 294 | FL("Collected BSS Description for Channel(%1d), length(%u), aniIndicator(%d), IE Fields(%u)"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 295 | pBssDescr->channelId, |
| 296 | pBssDescr->length, |
| 297 | pBssDescr->aniIndicator, |
| 298 | ieLen ); |
| 299 | |
Ganesh Kondabattini | 62feb16 | 2016-01-14 17:41:05 +0530 | [diff] [blame] | 300 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 301 | } /*** end limCollectBssDescription() ***/ |
| 302 | |
| 303 | /** |
| 304 | * limIsScanRequestedSSID() |
| 305 | * |
| 306 | *FUNCTION: |
| 307 | * This function is called during scan upon receiving |
| 308 | * Beacon/Probe Response frame to check if the received |
| 309 | * SSID is present in the list of requested SSIDs in scan |
| 310 | * |
| 311 | *LOGIC: |
| 312 | * |
| 313 | *ASSUMPTIONS: |
| 314 | * NA |
| 315 | * |
| 316 | *NOTE: |
| 317 | * NA |
| 318 | * |
| 319 | * @param pMac - Pointer to Global MAC structure |
| 320 | * @param ssId - SSID Received in beacons/Probe responses that is compared against the |
| 321 | requeusted SSID in scan list |
| 322 | * --------------------------------------------- |
| 323 | * |
| 324 | * @return boolean - TRUE if SSID is present in requested list, FALSE otherwise |
| 325 | */ |
| 326 | |
| 327 | tANI_BOOLEAN limIsScanRequestedSSID(tpAniSirGlobal pMac, tSirMacSSid *ssId) |
| 328 | { |
| 329 | tANI_U8 i = 0; |
| 330 | |
| 331 | for (i = 0; i < pMac->lim.gpLimMlmScanReq->numSsid; i++) |
| 332 | { |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 333 | if ( eANI_BOOLEAN_TRUE == vos_mem_compare((tANI_U8 *) ssId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 334 | (tANI_U8 *) &pMac->lim.gpLimMlmScanReq->ssId[i], |
| 335 | (tANI_U8) (pMac->lim.gpLimMlmScanReq->ssId[i].length + 1))) |
| 336 | { |
| 337 | return eANI_BOOLEAN_TRUE; |
| 338 | } |
| 339 | } |
| 340 | return eANI_BOOLEAN_FALSE; |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * limCheckAndAddBssDescription() |
| 345 | * |
| 346 | *FUNCTION: |
| 347 | * This function is called during scan upon receiving |
| 348 | * Beacon/Probe Response frame to check if the received |
| 349 | * frame matches scan criteria, collect BSS description |
| 350 | * and add it to cached scan results. |
| 351 | * |
| 352 | *LOGIC: |
| 353 | * |
| 354 | *ASSUMPTIONS: |
| 355 | * NA |
| 356 | * |
| 357 | *NOTE: |
| 358 | * NA |
| 359 | * |
| 360 | * @param pMac - Pointer to Global MAC structure |
| 361 | * @param pBPR - Pointer to parsed Beacon/Probe Response structure |
| 362 | * @param pRxPacketInfo - Pointer to Received frame's BD |
| 363 | * @param fScanning - boolean to indicate whether the BSS is from current scan or just happen to receive a beacon |
| 364 | * |
| 365 | * @return None |
| 366 | */ |
| 367 | |
| 368 | void |
| 369 | limCheckAndAddBssDescription(tpAniSirGlobal pMac, |
| 370 | tpSirProbeRespBeacon pBPR, |
| 371 | tANI_U8 *pRxPacketInfo, |
| 372 | tANI_BOOLEAN fScanning, |
| 373 | tANI_U8 fProbeRsp) |
| 374 | { |
| 375 | tLimScanResultNode *pBssDescr; |
| 376 | tANI_U32 frameLen, ieLen = 0; |
| 377 | tANI_U8 rxChannelInBeacon = 0; |
| 378 | eHalStatus status; |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 379 | tANI_U8 dontUpdateAll = 0; |
Leela Venkata Kiran Kumar Reddy Chirala | cdd1300 | 2013-10-16 15:43:47 -0700 | [diff] [blame] | 380 | tANI_U8 rfBand = 0; |
| 381 | tANI_U8 rxChannelInBD = 0; |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 382 | bool chan_info_present = true; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 383 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 384 | tSirMacAddr bssid = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
Agrawal Ashish | 9948e08 | 2014-07-17 13:48:37 +0530 | [diff] [blame] | 385 | tSirMacAddr bssid_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 386 | tANI_BOOLEAN fFound = FALSE; |
| 387 | tpSirMacDataHdr3a pHdr; |
| 388 | |
| 389 | pHdr = WDA_GET_RX_MPDUHEADER3A((tANI_U8 *)pRxPacketInfo); |
| 390 | |
Agrawal Ashish | 9948e08 | 2014-07-17 13:48:37 +0530 | [diff] [blame] | 391 | // Check For Null BSSID; Skip in case of P2P. |
| 392 | if (vos_mem_compare(bssid_zero, &pHdr->addr3, 6)) |
| 393 | { |
| 394 | return ; |
| 395 | } |
| 396 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 397 | //Checking if scanning for a particular BSSID |
| 398 | if ((fScanning) && (pMac->lim.gpLimMlmScanReq)) |
| 399 | { |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 400 | fFound = vos_mem_compare(pHdr->addr3, &pMac->lim.gpLimMlmScanReq->bssId, 6); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 401 | if (!fFound) |
| 402 | { |
| 403 | if ((pMac->lim.gpLimMlmScanReq->p2pSearch) && |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 404 | (vos_mem_compare(pBPR->P2PProbeRes.P2PDeviceInfo.P2PDeviceAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 405 | &pMac->lim.gpLimMlmScanReq->bssId, 6))) |
| 406 | { |
| 407 | fFound = eANI_BOOLEAN_TRUE; |
| 408 | } |
| 409 | } |
| 410 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 411 | |
| 412 | /** |
| 413 | * Compare SSID with the one sent in |
| 414 | * Probe Request frame, if any. |
| 415 | * If they don't match, ignore the |
| 416 | * Beacon frame. |
| 417 | * pMac->lim.gLimMlmScanReq->ssId.length == 0 |
| 418 | * indicates Broadcast SSID. |
| 419 | * When gLimReturnAfterFirstMatch is set, it means the scan has to match |
| 420 | * a SSID (if it is also set). Ignore the other BSS in that case. |
| 421 | */ |
| 422 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 423 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 424 | if (!(WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))) |
| 425 | { |
| 426 | #endif |
| 427 | if ((pMac->lim.gpLimMlmScanReq) && |
| 428 | (((fScanning) && |
| 429 | ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) && |
| 430 | (pMac->lim.gpLimMlmScanReq->numSsid) && |
| 431 | !limIsScanRequestedSSID(pMac, &pBPR->ssId)) || |
| 432 | (!fFound && (pMac->lim.gpLimMlmScanReq && |
| 433 | pMac->lim.gpLimMlmScanReq->bssId) && |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 434 | !vos_mem_compare(bssid, |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 435 | &pMac->lim.gpLimMlmScanReq->bssId, 6)))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 436 | { |
| 437 | /** |
| 438 | * Received SSID does not match with |
| 439 | * the one we're scanning for. |
| 440 | * Ignore received Beacon frame |
| 441 | */ |
| 442 | |
| 443 | return; |
| 444 | } |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 445 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 446 | } |
| 447 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 448 | |
| 449 | /* There is no point in caching & reporting the scan results for APs |
| 450 | * which are in the process of switching the channel. So, we are not |
| 451 | * caching the scan results for APs which are adverzing the channel-switch |
| 452 | * element in their beacons and probe responses. |
| 453 | */ |
Wu Gao | c3bfe0a | 2018-03-26 13:11:28 +0800 | [diff] [blame] | 454 | if(pBPR->channelSwitchPresent) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 455 | { |
Yeshwanth Sriram Guntuka | 3ad15d5 | 2018-04-16 14:34:25 +0530 | [diff] [blame] | 456 | if (pBPR->ext_chan_switch_ann.new_channel != |
| 457 | limGetChannelFromBeacon(pMac, pBPR)) |
| 458 | return; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 459 | } |
| 460 | |
Wu Gao | c3bfe0a | 2018-03-26 13:11:28 +0800 | [diff] [blame] | 461 | if(pBPR->ecsa_present) { |
| 462 | limLog(pMac, LOGW, FL("ECSA IE present")); |
| 463 | /* Still add to scan result if ECSA IE present and new channel |
| 464 | * equal to current channel. |
| 465 | */ |
| 466 | if (pBPR->channelNumber!= HAL_INVALID_CHANNEL_ID && |
| 467 | pBPR->ext_chan_switch_ann.new_channel != HAL_INVALID_CHANNEL_ID && |
| 468 | pBPR->channelNumber != pBPR->ext_chan_switch_ann.new_channel) { |
| 469 | limLog(pMac, LOGW, FL("ignore this AP")); |
| 470 | return; |
| 471 | } |
| 472 | |
| 473 | } |
| 474 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 475 | /* If beacon/probe resp DS param channel does not match with |
| 476 | * RX BD channel then don't save the results. It might be a beacon |
| 477 | * from another channel heard as noise on the current scanning channel |
| 478 | */ |
| 479 | |
Leela Venkata Kiran Kumar Reddy Chirala | cdd1300 | 2013-10-16 15:43:47 -0700 | [diff] [blame] | 480 | if ((pBPR->dsParamsPresent) || (pBPR->HTInfo.present)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 481 | { |
| 482 | /* This means that we are in 2.4GHz mode or 5GHz 11n mode */ |
| 483 | rxChannelInBeacon = limGetChannelFromBeacon(pMac, pBPR); |
Leela Venkata Kiran Kumar Reddy Chirala | cdd1300 | 2013-10-16 15:43:47 -0700 | [diff] [blame] | 484 | rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo); |
| 485 | rxChannelInBD = WDA_GET_RX_CH(pRxPacketInfo); |
| 486 | |
| 487 | if ((!rfBand) || IS_5G_BAND(rfBand)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 488 | { |
Leela Venkata Kiran Kumar Reddy Chirala | cdd1300 | 2013-10-16 15:43:47 -0700 | [diff] [blame] | 489 | rxChannelInBD = limUnmapChannel(rxChannelInBD); |
| 490 | } |
| 491 | |
| 492 | if(rxChannelInBD != rxChannelInBeacon) |
| 493 | { |
| 494 | /* BCAST Frame, if CH do not match, Drop */ |
| 495 | if(WDA_IS_RX_BCAST(pRxPacketInfo)) |
| 496 | { |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 497 | limLog(pMac, LOG3, FL("Beacon/Probe Rsp dropped. Channel in BD %d. " |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 498 | "Channel in beacon" " %d"), |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 499 | WDA_GET_RX_CH(pRxPacketInfo),limGetChannelFromBeacon(pMac, pBPR)); |
| 500 | return; |
Leela Venkata Kiran Kumar Reddy Chirala | cdd1300 | 2013-10-16 15:43:47 -0700 | [diff] [blame] | 501 | } |
| 502 | /* Unit cast frame, Probe RSP, do not drop */ |
| 503 | else |
| 504 | { |
| 505 | dontUpdateAll = 1; |
| 506 | limLog(pMac, LOG3, FL("SSID %s, CH in ProbeRsp %d, CH in BD %d, miss-match, Do Not Drop"), |
| 507 | pBPR->ssId.ssId, |
| 508 | rxChannelInBeacon, |
| 509 | WDA_GET_RX_CH(pRxPacketInfo)); |
| 510 | WDA_GET_RX_CH(pRxPacketInfo) = rxChannelInBeacon; |
| 511 | } |
| 512 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 513 | } |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 514 | else |
| 515 | { |
| 516 | chan_info_present = false; |
| 517 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 518 | |
| 519 | /** |
| 520 | * Allocate buffer to hold BSS description from |
| 521 | * received Beacon frame. |
| 522 | * Include size of fixed fields and IEs length |
| 523 | */ |
| 524 | |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 525 | ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo); |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 526 | if (ieLen <= (SIR_MAC_B_PR_SSID_OFFSET + 2)) |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 527 | { |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 528 | limLog(pMac, LOGP, |
| 529 | FL("RX packet has invalid length %d"), ieLen); |
| 530 | return; |
Leela V Kiran Kumar Reddy Chirala | 6a45875 | 2013-02-16 15:41:27 -0800 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | ieLen -= SIR_MAC_B_PR_SSID_OFFSET; |
| 534 | |
| 535 | frameLen = sizeof(tLimScanResultNode) + ieLen - sizeof(tANI_U32); //Sizeof(tANI_U32) is for ieFields[1] |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 536 | |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 537 | pBssDescr = vos_mem_malloc(frameLen); |
| 538 | if ( NULL == pBssDescr ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 539 | { |
| 540 | // Log error |
| 541 | limLog(pMac, LOGP, |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 542 | FL("call for AllocateMemory failed for storing BSS description")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 543 | |
| 544 | return; |
| 545 | } |
| 546 | |
Padma, Santhosh Kumar | f21a0d9 | 2015-11-02 12:41:06 +0530 | [diff] [blame] | 547 | vos_mem_zero(pBssDescr, frameLen); |
| 548 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 549 | // In scan state, store scan result. |
| 550 | #if defined WLAN_FEATURE_VOWIFI |
Ganesh Kondabattini | 62feb16 | 2016-01-14 17:41:05 +0530 | [diff] [blame] | 551 | limCollectBssDescription(pMac, &pBssDescr->bssDescription, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 552 | pBPR, pRxPacketInfo, fScanning); |
| 553 | #else |
Ganesh Kondabattini | 62feb16 | 2016-01-14 17:41:05 +0530 | [diff] [blame] | 554 | limCollectBssDescription(pMac, &pBssDescr->bssDescription, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 555 | pBPR, pRxPacketInfo); |
| 556 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 557 | pBssDescr->bssDescription.fProbeRsp = fProbeRsp; |
| 558 | |
| 559 | pBssDescr->next = NULL; |
| 560 | |
| 561 | /** |
| 562 | * Depending on whether to store unique or all |
| 563 | * scan results, pass hash update/add parameter |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 564 | * For LFR candidates just add them on it's own cache |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 565 | */ |
| 566 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 567 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 568 | if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo)) |
| 569 | { |
Padma, Santhosh Kumar | 30971cf | 2015-04-06 19:59:37 +0530 | [diff] [blame] | 570 | limLog(pMac, LOG1, FL(" pHdr->addr1:"MAC_ADDRESS_STR), |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 571 | MAC_ADDR_ARRAY(pHdr->addr1)); |
Padma, Santhosh Kumar | 30971cf | 2015-04-06 19:59:37 +0530 | [diff] [blame] | 572 | limLog(pMac, LOG1, FL(" pHdr->addr2:"MAC_ADDRESS_STR), |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 573 | MAC_ADDR_ARRAY(pHdr->addr2)); |
Padma, Santhosh Kumar | 30971cf | 2015-04-06 19:59:37 +0530 | [diff] [blame] | 574 | limLog(pMac, LOG1, FL(" pHdr->addr3:"MAC_ADDRESS_STR), |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 575 | MAC_ADDR_ARRAY(pHdr->addr3)); |
Padma, Santhosh Kumar | 30971cf | 2015-04-06 19:59:37 +0530 | [diff] [blame] | 576 | limLog( pMac, LOG1, FL("Save this entry in LFR cache")); |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 577 | status = limLookupNaddLfrHashEntry(pMac, pBssDescr, LIM_HASH_ADD, |
| 578 | dontUpdateAll, ieLen - 2); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 579 | } |
| 580 | else |
| 581 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 582 | //If it is not scanning, only save unique results |
| 583 | if (pMac->lim.gLimReturnUniqueResults || (!fScanning)) |
| 584 | { |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 585 | status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_UPDATE, |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 586 | dontUpdateAll, ieLen - 2, |
| 587 | chan_info_present); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 588 | } |
| 589 | else |
| 590 | { |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 591 | status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_ADD, |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 592 | dontUpdateAll, ieLen - 2, |
| 593 | chan_info_present); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | if(fScanning) |
| 597 | { |
| 598 | if ((pBssDescr->bssDescription.channelId <= 14) && |
| 599 | (pMac->lim.gLimReturnAfterFirstMatch & 0x40) && |
| 600 | pBPR->countryInfoPresent) |
| 601 | pMac->lim.gLim24Band11dScanDone = 1; |
| 602 | |
| 603 | if ((pBssDescr->bssDescription.channelId > 14) && |
| 604 | (pMac->lim.gLimReturnAfterFirstMatch & 0x80) && |
| 605 | pBPR->countryInfoPresent) |
| 606 | pMac->lim.gLim50Band11dScanDone = 1; |
| 607 | |
| 608 | if ( ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) || |
| 609 | ( pMac->lim.gLim24Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x40 ) ) || |
Gopichand Nakkala | 48b4d7e | 2013-03-06 23:34:16 +0530 | [diff] [blame] | 610 | ( pMac->lim.gLim50Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x80 ) ) || |
| 611 | fFound ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 612 | { |
| 613 | /** |
| 614 | * Stop scanning and return the BSS description(s) |
| 615 | * collected so far. |
| 616 | */ |
| 617 | limLog(pMac, |
| 618 | LOGW, |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 619 | FL("Completed scan: 24Band11dScan = %d, 50Band11dScan = %d BSS id"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 620 | pMac->lim.gLim24Band11dScanDone, |
| 621 | pMac->lim.gLim50Band11dScanDone); |
| 622 | |
| 623 | //Need to disable the timers. If they fire, they will send END_SCAN |
| 624 | //while we already send FINISH_SCAN here. This may mess up the gLimHalScanState |
| 625 | limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER); |
| 626 | limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER); |
| 627 | //Set the resume channel to Any valid channel (invalid). |
| 628 | //This will instruct HAL to set it to any previous valid channel. |
| 629 | peSetResumeChannel(pMac, 0, 0); |
| 630 | limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE ); |
| 631 | //limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE ); |
| 632 | } |
| 633 | }//(eANI_BOOLEAN_TRUE == fScanning) |
| 634 | |
| 635 | if( eHAL_STATUS_SUCCESS != status ) |
| 636 | { |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 637 | vos_mem_free( pBssDescr ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 638 | } |
| 639 | } /****** end limCheckAndAddBssDescription() ******/ |
| 640 | |
| 641 | |
| 642 | |
| 643 | /** |
| 644 | * limScanHashFunction() |
| 645 | * |
| 646 | *FUNCTION: |
| 647 | * This function is called during scan hash entry operations |
| 648 | * |
| 649 | *LOGIC: |
| 650 | * |
| 651 | *ASSUMPTIONS: |
| 652 | * NA |
| 653 | * |
| 654 | *NOTE: |
| 655 | * NA |
| 656 | * |
| 657 | * @param bssId - Received BSSid |
| 658 | * |
| 659 | * @return Hash index |
| 660 | */ |
| 661 | |
| 662 | tANI_U8 |
| 663 | limScanHashFunction(tSirMacAddr bssId) |
| 664 | { |
| 665 | tANI_U16 i, hash = 0; |
| 666 | |
| 667 | for (i = 0; i < sizeof(tSirMacAddr); i++) |
| 668 | hash += bssId[i]; |
| 669 | |
| 670 | return hash % LIM_MAX_NUM_OF_SCAN_RESULTS; |
| 671 | } /****** end limScanHashFunction() ******/ |
| 672 | |
| 673 | |
| 674 | |
| 675 | /** |
| 676 | * limInitHashTable() |
| 677 | * |
| 678 | *FUNCTION: |
| 679 | * This function is called upon receiving SME_START_REQ |
| 680 | * to initialize global cached scan hash table |
| 681 | * |
| 682 | *LOGIC: |
| 683 | * |
| 684 | *ASSUMPTIONS: |
| 685 | * NA |
| 686 | * |
| 687 | *NOTE: |
| 688 | * NA |
| 689 | * |
| 690 | * @param pMac - Pointer to Global MAC structure |
| 691 | * @return None |
| 692 | */ |
| 693 | |
| 694 | void |
| 695 | limInitHashTable(tpAniSirGlobal pMac) |
| 696 | { |
| 697 | tANI_U16 i; |
| 698 | for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++) |
| 699 | pMac->lim.gLimCachedScanHashTable[i] = NULL; |
| 700 | } /****** end limInitHashTable() ******/ |
| 701 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 702 | eHalStatus |
| 703 | limLookupNaddHashEntry(tpAniSirGlobal pMac, |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 704 | tLimScanResultNode *pBssDescr, tANI_U8 action, |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 705 | tANI_U8 dontUpdateAll, tANI_U32 ie_len, |
| 706 | bool chan_info_present) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 707 | { |
Madan Mohan Koyyalamudi | ca43cdf | 2012-09-24 13:15:49 -0700 | [diff] [blame] | 708 | tANI_U8 index, ssidLen = 0; |
| 709 | tANI_U8 found = false; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 710 | tLimScanResultNode *ptemp, *pprev; |
| 711 | tSirMacCapabilityInfo *pSirCap, *pSirCapTemp; |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 712 | int len, elem_id, elem_len; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 713 | tANI_U8 *pbIe; |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 714 | tANI_S8 rssi = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 715 | |
| 716 | index = limScanHashFunction(pBssDescr->bssDescription.bssId); |
| 717 | ptemp = pMac->lim.gLimCachedScanHashTable[index]; |
| 718 | |
| 719 | //ieFields start with TLV of SSID IE |
| 720 | ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1); |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 721 | if ((ssidLen > ie_len) || (ssidLen > DOT11F_IE_SSID_MAX_LEN)) { |
| 722 | limLog(pMac, LOGE, FL("SSID length %d, IE overall Length %d"), |
| 723 | ssidLen, ie_len); |
| 724 | return eHAL_STATUS_FAILURE; |
| 725 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 726 | pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo; |
| 727 | |
| 728 | for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next) |
| 729 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 730 | //For infrastructure, check BSSID and SSID. For IBSS, check more |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 731 | pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo; |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 732 | if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first |
| 733 | (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 734 | (tANI_U8 *) ptemp->bssDescription.bssId, |
| 735 | sizeof(tSirMacAddr))) && //matching BSSID |
Abhishek Singh | e3fa11f | 2014-05-13 11:11:10 +0530 | [diff] [blame] | 736 | // matching band to update new channel info |
| 737 | (vos_chan_to_band(pBssDescr->bssDescription.channelId) == |
| 738 | vos_chan_to_band(ptemp->bssDescription.channelId)) && |
Abhinav Kumar | 2d59028 | 2018-06-28 11:45:15 +0530 | [diff] [blame] | 739 | (*((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1) == |
| 740 | *((tANI_U8 *) &ptemp->bssDescription.ieFields + 1)) && |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 741 | vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 742 | ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1), |
| 743 | (tANI_U8) (ssidLen + 1)) && |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 744 | ((pSirCapTemp->ess) || //we are done for infrastructure |
| 745 | //For IBSS, nwType and channelId |
| 746 | (((pBssDescr->bssDescription.nwType == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 747 | ptemp->bssDescription.nwType) && |
| 748 | (pBssDescr->bssDescription.channelId == |
| 749 | ptemp->bssDescription.channelId)))) |
| 750 | ) |
| 751 | { |
| 752 | // Found the same BSS description |
| 753 | if (action == LIM_HASH_UPDATE) |
| 754 | { |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 755 | if(dontUpdateAll) |
| 756 | { |
| 757 | rssi = ptemp->bssDescription.rssi; |
| 758 | } |
| 759 | |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 760 | if(pBssDescr->bssDescription.fProbeRsp != |
| 761 | ptemp->bssDescription.fProbeRsp) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 762 | { |
| 763 | //We get a different, save the old frame WSC IE if it is there |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 764 | len = ptemp->bssDescription.length - |
| 765 | sizeof(tSirBssDescription) + |
| 766 | sizeof(tANI_U16) + sizeof(tANI_U32); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 767 | pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields; |
| 768 | //Save WPS IE if it exists |
| 769 | pBssDescr->bssDescription.WscIeLen = 0; |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 770 | while (len >= 2) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 771 | { |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 772 | elem_id = pbIe[0]; |
| 773 | elem_len = pbIe[1]; |
| 774 | len -= 2; |
| 775 | if (elem_len > len) { |
| 776 | limLog(pMac, LOGW, FL("Invalid eid: %d elem_len: %d left: %d"), |
| 777 | elem_id, elem_len, len); |
| 778 | return eHAL_STATUS_FAILURE; |
| 779 | } |
| 780 | if ((elem_id == DOT11F_EID_WSCPROBERES) && |
| 781 | (elem_len >= DOT11F_IE_WSCPROBERES_MIN_LEN) && |
| 782 | ((pbIe[2] == 0x00) && (pbIe[3] == 0x50) && |
| 783 | (pbIe[4] == 0xf2) && |
| 784 | (pbIe[5] == 0x04))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 785 | { |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 786 | if((elem_len + 2) <= WSCIE_PROBE_RSP_LEN) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 787 | { |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 788 | vos_mem_copy( |
| 789 | pBssDescr->bssDescription.WscIeProbeRsp, |
| 790 | pbIe, elem_len + 2); |
| 791 | pBssDescr->bssDescription.WscIeLen = |
| 792 | elem_len + 2; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 793 | } |
| 794 | break; |
| 795 | } |
Abhishek Singh | 02b08ed | 2018-09-26 15:04:58 +0530 | [diff] [blame] | 796 | len -= elem_len; |
| 797 | pbIe += (elem_len + 2); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 798 | } |
| 799 | } |
Abhishek Singh | 56c2981 | 2018-06-12 14:07:52 +0530 | [diff] [blame] | 800 | /* |
| 801 | * Due to Rx sensitivity issue, sometime beacons are seen on |
| 802 | * adjacent channel so workaround in software is needed. If DS |
| 803 | * params or HT info are present driver can get proper channel |
| 804 | * info from these IEs and the older RSSI values are used in new |
| 805 | * entry. |
| 806 | * |
| 807 | * For the cases where DS params and HT info is not present, |
| 808 | * driver needs to check below conditions to update proper |
| 809 | * channel so that the older RSSI and channel values are used in |
| 810 | * new entry: |
| 811 | * -- The old entry channel and new entry channel are not same |
| 812 | * -- RSSI is below 15db or more from old value, this indicate |
| 813 | * that the signal has leaked in adjacent channel |
| 814 | */ |
| 815 | if (!pBssDescr->bssDescription.fProbeRsp && |
| 816 | !chan_info_present && |
| 817 | (pBssDescr->bssDescription.channelId != |
| 818 | ptemp->bssDescription.channelId) && |
| 819 | ((ptemp->bssDescription.rssi - |
| 820 | pBssDescr->bssDescription.rssi) > |
| 821 | SIR_ADJACENT_CHANNEL_RSSI_DIFF_THRESHOLD)) { |
| 822 | pBssDescr->bssDescription.channelId = |
| 823 | ptemp->bssDescription.channelId; |
| 824 | pBssDescr->bssDescription.rssi = |
| 825 | ptemp->bssDescription.rssi; |
| 826 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 827 | |
| 828 | |
| 829 | if(NULL != pMac->lim.gpLimMlmScanReq) |
| 830 | { |
| 831 | if((pMac->lim.gpLimMlmScanReq->numSsid)&& |
| 832 | ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *) |
| 833 | &pBssDescr->bssDescription.ieFields + 1)))) |
| 834 | return eHAL_STATUS_FAILURE; |
| 835 | } |
| 836 | |
| 837 | // Delete this entry |
Madan Mohan Koyyalamudi | ca43cdf | 2012-09-24 13:15:49 -0700 | [diff] [blame] | 838 | if (ptemp == pMac->lim.gLimCachedScanHashTable[index]) |
| 839 | pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 840 | else |
Madan Mohan Koyyalamudi | ca43cdf | 2012-09-24 13:15:49 -0700 | [diff] [blame] | 841 | pprev->next = ptemp->next; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 842 | |
Madan Mohan Koyyalamudi | ca43cdf | 2012-09-24 13:15:49 -0700 | [diff] [blame] | 843 | pMac->lim.gLimMlmScanResultLength -= |
| 844 | ptemp->bssDescription.length + sizeof(tANI_U16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 845 | |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 846 | vos_mem_free(ptemp); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 847 | } |
Madan Mohan Koyyalamudi | ca43cdf | 2012-09-24 13:15:49 -0700 | [diff] [blame] | 848 | found = true; |
| 849 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 850 | } |
| 851 | } |
| 852 | |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 853 | //for now, only rssi, we can add more if needed |
Madan Mohan Koyyalamudi | 3e9f202 | 2012-12-04 16:34:19 -0800 | [diff] [blame] | 854 | if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi) |
Madan Mohan Koyyalamudi | 1586559 | 2012-09-28 15:55:37 -0700 | [diff] [blame] | 855 | { |
| 856 | pBssDescr->bssDescription.rssi = rssi; |
| 857 | } |
| 858 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 859 | // Add this BSS description at same index |
| 860 | if (pprev == pMac->lim.gLimCachedScanHashTable[index]) |
| 861 | { |
| 862 | pBssDescr->next = pMac->lim.gLimCachedScanHashTable[index]; |
| 863 | pMac->lim.gLimCachedScanHashTable[index] = pBssDescr; |
| 864 | } |
| 865 | else |
| 866 | { |
| 867 | pBssDescr->next = pprev->next; |
| 868 | pprev->next = pBssDescr; |
| 869 | } |
| 870 | pMac->lim.gLimMlmScanResultLength += |
| 871 | pBssDescr->bssDescription.length + sizeof(tANI_U16); |
| 872 | |
Kiran Kumar Lokere | 5be73a6 | 2013-04-01 18:40:00 -0700 | [diff] [blame] | 873 | PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 874 | pBssDescr->bssDescription.length, |
| 875 | pMac->lim.gLimMlmScanResultLength); |
| 876 | limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);) |
| 877 | |
| 878 | // Send new BSS found indication to HDD if CFG option is set |
| 879 | if (!found) limSendSmeNeighborBssInd(pMac, pBssDescr); |
| 880 | |
| 881 | // |
| 882 | // TODO: IF applicable, do we need to send: |
| 883 | // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF |
| 884 | // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP |
| 885 | // |
| 886 | return eHAL_STATUS_SUCCESS; |
| 887 | } |
| 888 | |
| 889 | |
| 890 | |
| 891 | /** |
| 892 | * limDeleteHashEntry() |
| 893 | * |
| 894 | *FUNCTION: |
| 895 | * This function is called upon to delete |
| 896 | * a BSS description from scan result hash table. |
| 897 | * |
| 898 | *LOGIC: |
| 899 | * |
| 900 | *ASSUMPTIONS: |
| 901 | * NA |
| 902 | * |
| 903 | *NOTE: |
| 904 | * Yet to find the utility of the function |
| 905 | * |
| 906 | * @param pBssDescr - Pointer to BSS description to be |
| 907 | * deleted from the scan result hash table. |
| 908 | * |
| 909 | * @return None |
| 910 | */ |
| 911 | |
| 912 | void limDeleteHashEntry(tLimScanResultNode *pBssDescr) |
| 913 | { |
| 914 | } /****** end limDeleteHashEntry() ******/ |
| 915 | |
| 916 | |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 917 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 918 | /** |
| 919 | * limInitLfrHashTable() |
| 920 | * |
| 921 | *FUNCTION: |
| 922 | * This function is called upon receiving SME_START_REQ |
| 923 | * to initialize global cached Lfr scan hash table |
| 924 | * |
| 925 | *LOGIC: |
| 926 | * |
| 927 | *ASSUMPTIONS: |
| 928 | * NA |
| 929 | * |
| 930 | *NOTE: |
| 931 | * NA |
| 932 | * |
| 933 | * @param pMac - Pointer to Global MAC structure |
| 934 | * @return None |
| 935 | */ |
| 936 | |
| 937 | void |
| 938 | limInitLfrHashTable(tpAniSirGlobal pMac) |
| 939 | { |
| 940 | tANI_U16 i; |
| 941 | for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++) |
| 942 | pMac->lim.gLimCachedLfrScanHashTable[i] = NULL; |
| 943 | } /****** end limInitLfrHashTable() ******/ |
| 944 | |
| 945 | |
| 946 | |
| 947 | /** |
| 948 | * limLookupNaddLfrHashEntry() |
| 949 | * |
| 950 | *FUNCTION: |
| 951 | * This function is called upon receiving a Beacon or |
| 952 | * Probe Response frame during Lfr scan phase from FW to store |
| 953 | * received BSS description into Lfr scan result hash table. |
| 954 | * |
| 955 | *LOGIC: |
| 956 | * |
| 957 | *ASSUMPTIONS: |
| 958 | * NA |
| 959 | * |
| 960 | *NOTE: |
| 961 | * NA |
| 962 | * |
| 963 | * @param pMac - Pointer to Global MAC structure |
| 964 | * @param pBssDescr - Pointer to BSS description to be |
| 965 | * added to the Lfr scan result hash table. |
| 966 | * @param action - Indicates action to be performed |
| 967 | * when same BSS description is found. This is |
| 968 | * dependent on whether unique scan result to |
| 969 | * be stored or not. |
| 970 | * |
| 971 | * @return None |
| 972 | */ |
| 973 | |
| 974 | eHalStatus |
| 975 | limLookupNaddLfrHashEntry(tpAniSirGlobal pMac, |
| 976 | tLimScanResultNode *pBssDescr, tANI_U8 action, |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 977 | tANI_U8 dontUpdateAll, tANI_U32 ie_len) |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 978 | { |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 979 | tANI_U8 index, ssidLen = 0; |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 980 | tLimScanResultNode *ptemp, *pprev; |
| 981 | tSirMacCapabilityInfo *pSirCap, *pSirCapTemp; |
| 982 | int idx, len; |
| 983 | tANI_U8 *pbIe; |
| 984 | tANI_S8 rssi = 0; |
| 985 | |
| 986 | index = limScanHashFunction(pBssDescr->bssDescription.bssId); |
| 987 | ptemp = pMac->lim.gLimCachedLfrScanHashTable[index]; |
| 988 | |
| 989 | //ieFields start with TLV of SSID IE |
| 990 | ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1); |
Abhinav Kumar | b2347d4 | 2018-06-13 12:44:14 +0530 | [diff] [blame] | 991 | if ((ssidLen > ie_len) || (ssidLen > DOT11F_IE_SSID_MAX_LEN)) { |
| 992 | limLog(pMac, LOGE, FL("SSID length %d, IE overall Length %d"), |
| 993 | ssidLen, ie_len); |
| 994 | return eHAL_STATUS_FAILURE; |
| 995 | } |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 996 | pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo; |
| 997 | |
| 998 | for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next) |
| 999 | { |
| 1000 | //For infrastructure, check BSSID and SSID. For IBSS, check more |
| 1001 | pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo; |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 1002 | if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first |
| 1003 | (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId, |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1004 | (tANI_U8 *) ptemp->bssDescription.bssId, |
| 1005 | sizeof(tSirMacAddr))) && //matching BSSID |
| 1006 | (pBssDescr->bssDescription.channelId == |
| 1007 | ptemp->bssDescription.channelId) && |
Abhinav Kumar | 2d59028 | 2018-06-28 11:45:15 +0530 | [diff] [blame] | 1008 | (*((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1) == |
| 1009 | *((tANI_U8 *) &ptemp->bssDescription.ieFields + 1)) && |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 1010 | vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1), |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1011 | ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1), |
| 1012 | (tANI_U8) (ssidLen + 1)) && |
| 1013 | ((pSirCapTemp->ess) || //we are done for infrastructure |
| 1014 | //For IBSS, nwType and channelId |
| 1015 | (((pBssDescr->bssDescription.nwType == |
| 1016 | ptemp->bssDescription.nwType) && |
| 1017 | (pBssDescr->bssDescription.channelId == |
| 1018 | ptemp->bssDescription.channelId)))) |
| 1019 | ) |
| 1020 | { |
| 1021 | // Found the same BSS description |
| 1022 | if (action == LIM_HASH_UPDATE) |
| 1023 | { |
| 1024 | if(dontUpdateAll) |
| 1025 | { |
| 1026 | rssi = ptemp->bssDescription.rssi; |
| 1027 | } |
| 1028 | |
| 1029 | if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp) |
| 1030 | { |
| 1031 | //We get a different, save the old frame WSC IE if it is there |
| 1032 | idx = 0; |
| 1033 | len = ptemp->bssDescription.length - sizeof(tSirBssDescription) + |
| 1034 | sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2; |
| 1035 | pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields; |
| 1036 | //Save WPS IE if it exists |
| 1037 | pBssDescr->bssDescription.WscIeLen = 0; |
| 1038 | while(idx < len) |
| 1039 | { |
| 1040 | if((DOT11F_EID_WSCPROBERES == pbIe[0]) && |
| 1041 | (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && |
| 1042 | (0xf2 == pbIe[4]) && (0x04 == pbIe[5])) |
| 1043 | { |
| 1044 | //Found it |
| 1045 | if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1]) |
| 1046 | { |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 1047 | vos_mem_copy( pBssDescr->bssDescription.WscIeProbeRsp, |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1048 | pbIe, pbIe[1] + 2); |
| 1049 | pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2; |
| 1050 | } |
| 1051 | break; |
| 1052 | } |
| 1053 | idx += pbIe[1] + 2; |
| 1054 | pbIe += pbIe[1] + 2; |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | |
| 1059 | if(NULL != pMac->lim.gpLimMlmScanReq) |
| 1060 | { |
| 1061 | if((pMac->lim.gpLimMlmScanReq->numSsid)&& |
| 1062 | ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *) |
| 1063 | &pBssDescr->bssDescription.ieFields + 1)))) |
| 1064 | return eHAL_STATUS_FAILURE; |
| 1065 | } |
| 1066 | |
| 1067 | // Delete this entry |
| 1068 | if (ptemp == pMac->lim.gLimCachedLfrScanHashTable[index]) |
| 1069 | pprev = pMac->lim.gLimCachedLfrScanHashTable[index] = ptemp->next; |
| 1070 | else |
| 1071 | pprev->next = ptemp->next; |
| 1072 | |
| 1073 | pMac->lim.gLimMlmLfrScanResultLength -= |
| 1074 | ptemp->bssDescription.length + sizeof(tANI_U16); |
| 1075 | |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 1076 | vos_mem_free(ptemp); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1077 | } |
| 1078 | break; |
| 1079 | } |
| 1080 | } |
| 1081 | |
| 1082 | //for now, only rssi, we can add more if needed |
| 1083 | if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi) |
| 1084 | { |
| 1085 | pBssDescr->bssDescription.rssi = rssi; |
| 1086 | } |
| 1087 | |
| 1088 | // Add this BSS description at same index |
| 1089 | if (pprev == pMac->lim.gLimCachedLfrScanHashTable[index]) |
| 1090 | { |
| 1091 | pBssDescr->next = pMac->lim.gLimCachedLfrScanHashTable[index]; |
| 1092 | pMac->lim.gLimCachedLfrScanHashTable[index] = pBssDescr; |
| 1093 | } |
| 1094 | else |
| 1095 | { |
| 1096 | pBssDescr->next = pprev->next; |
| 1097 | pprev->next = pBssDescr; |
| 1098 | } |
| 1099 | pMac->lim.gLimMlmLfrScanResultLength += |
| 1100 | pBssDescr->bssDescription.length + sizeof(tANI_U16); |
| 1101 | |
| 1102 | PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id\n"), |
| 1103 | pBssDescr->bssDescription.length, |
| 1104 | pMac->lim.gLimMlmLfrScanResultLength); |
| 1105 | limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);) |
| 1106 | |
| 1107 | // |
| 1108 | // TODO: IF applicable, do we need to send: |
| 1109 | // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF |
| 1110 | // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP |
| 1111 | // |
| 1112 | return eHAL_STATUS_SUCCESS; |
| 1113 | } |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | /** |
| 1118 | * limDeleteLfrHashEntry() |
| 1119 | * |
| 1120 | *FUNCTION: |
| 1121 | * This function is called upon to delete |
| 1122 | * a BSS description from LFR scan result hash table. |
| 1123 | * |
| 1124 | *LOGIC: |
| 1125 | * |
| 1126 | *ASSUMPTIONS: |
| 1127 | * NA |
| 1128 | * |
| 1129 | *NOTE: |
| 1130 | * Yet to find the utility of the function |
| 1131 | * |
| 1132 | * @param pBssDescr - Pointer to BSS description to be |
| 1133 | * deleted from the LFR scan result hash table. |
| 1134 | * |
| 1135 | * @return None |
| 1136 | */ |
| 1137 | |
| 1138 | void limDeleteLfrHashEntry(tLimScanResultNode *pBssDescr) |
| 1139 | { |
| 1140 | } /****** end limDeleteLfrHashEntry() ******/ |
| 1141 | |
| 1142 | #endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1143 | |
| 1144 | /** |
| 1145 | * limCopyScanResult() |
| 1146 | * |
| 1147 | *FUNCTION: |
| 1148 | * This function is called by limProcessSmeMessages() while |
| 1149 | * sending SME_SCAN_RSP with scan result to HDD. |
| 1150 | * |
| 1151 | *LOGIC: |
| 1152 | * This function traverses the scan list stored in scan hash table |
| 1153 | * |
| 1154 | *ASSUMPTIONS: |
| 1155 | * NA |
| 1156 | * |
| 1157 | *NOTE: |
| 1158 | * NA |
| 1159 | * |
| 1160 | * @param pMac - Pointer to Global MAC structure |
| 1161 | * @param pDest - Destination pointer |
| 1162 | * |
| 1163 | * @return None |
| 1164 | */ |
| 1165 | |
| 1166 | void |
| 1167 | limCopyScanResult(tpAniSirGlobal pMac, tANI_U8 *pDest) |
| 1168 | { |
| 1169 | tLimScanResultNode *ptemp; |
| 1170 | tANI_U16 i; |
| 1171 | for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++) |
| 1172 | { |
| 1173 | if ((ptemp = pMac->lim.gLimCachedScanHashTable[i]) != NULL) |
| 1174 | { |
| 1175 | while(ptemp) |
| 1176 | { |
| 1177 | /// Copy entire BSS description including length |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 1178 | vos_mem_copy( pDest, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1179 | (tANI_U8 *) &ptemp->bssDescription, |
| 1180 | ptemp->bssDescription.length + 2); |
| 1181 | pDest += ptemp->bssDescription.length + 2; |
| 1182 | ptemp = ptemp->next; |
| 1183 | } |
| 1184 | } |
| 1185 | } |
| 1186 | } /****** end limCopyScanResult() ******/ |
| 1187 | |
| 1188 | |
| 1189 | |
| 1190 | /** |
| 1191 | * limDeleteCachedScanResults() |
| 1192 | * |
| 1193 | *FUNCTION: |
| 1194 | * This function is called by limProcessSmeMessages() upon receiving |
| 1195 | * SME_SCAN_REQ with fresh scan result flag set. |
| 1196 | * |
| 1197 | *LOGIC: |
| 1198 | * This function traverses the scan list stored in scan hash table |
| 1199 | * and deletes the entries if any |
| 1200 | * |
| 1201 | *ASSUMPTIONS: |
| 1202 | * NA |
| 1203 | * |
| 1204 | *NOTE: |
| 1205 | * NA |
| 1206 | * |
| 1207 | * @param pMac - Pointer to Global MAC structure |
| 1208 | * @return None |
| 1209 | */ |
| 1210 | |
| 1211 | void |
| 1212 | limDeleteCachedScanResults(tpAniSirGlobal pMac) |
| 1213 | { |
| 1214 | tLimScanResultNode *pNode, *pNextNode; |
| 1215 | tANI_U16 i; |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 1216 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1217 | for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++) |
| 1218 | { |
| 1219 | if ((pNode = pMac->lim.gLimCachedScanHashTable[i]) != NULL) |
| 1220 | { |
| 1221 | while (pNode) |
| 1222 | { |
| 1223 | pNextNode = pNode->next; |
| 1224 | |
| 1225 | // Delete the current node |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 1226 | vos_mem_free(pNode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1227 | |
| 1228 | pNode = pNextNode; |
| 1229 | } |
| 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | pMac->lim.gLimSmeScanResultLength = 0; |
| 1234 | } /****** end limDeleteCachedScanResults() ******/ |
| 1235 | |
| 1236 | |
| 1237 | |
| 1238 | /** |
| 1239 | * limReInitScanResults() |
| 1240 | * |
| 1241 | *FUNCTION: |
| 1242 | * This function is called delete exisiting scan results |
| 1243 | * and initialize the scan hash table |
| 1244 | * |
| 1245 | *LOGIC: |
| 1246 | * |
| 1247 | *ASSUMPTIONS: |
| 1248 | * NA |
| 1249 | * |
| 1250 | *NOTE: |
| 1251 | * NA |
| 1252 | * |
| 1253 | * @param pMac - Pointer to Global MAC structure |
| 1254 | * @return None |
| 1255 | */ |
| 1256 | |
| 1257 | void |
| 1258 | limReInitScanResults(tpAniSirGlobal pMac) |
| 1259 | { |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 1260 | limLog(pMac, LOG1, FL("Re initialize scan hash table.")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1261 | limDeleteCachedScanResults(pMac); |
| 1262 | limInitHashTable(pMac); |
| 1263 | |
| 1264 | // !!LAC - need to clear out the global scan result length |
| 1265 | // since the list was just purged from the hash table. |
| 1266 | pMac->lim.gLimMlmScanResultLength = 0; |
| 1267 | |
| 1268 | } /****** end limReInitScanResults() ******/ |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1269 | #ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD |
| 1270 | /** |
| 1271 | * limDeleteCachedLfrScanResults() |
| 1272 | * |
| 1273 | *FUNCTION: |
| 1274 | * This function is called by limProcessSmeMessages() upon receiving |
| 1275 | * SME_SCAN_REQ with flush scan result flag set for LFR. |
| 1276 | * |
| 1277 | *LOGIC: |
| 1278 | * This function traverses the scan list stored in lfr scan hash |
| 1279 | * table and deletes the entries if any |
| 1280 | * |
| 1281 | *ASSUMPTIONS: |
| 1282 | * NA |
| 1283 | * |
| 1284 | *NOTE: |
| 1285 | * NA |
| 1286 | * |
| 1287 | * @param pMac - Pointer to Global MAC structure |
| 1288 | * @return None |
| 1289 | */ |
| 1290 | |
| 1291 | void |
| 1292 | limDeleteCachedLfrScanResults(tpAniSirGlobal pMac) |
| 1293 | { |
| 1294 | tLimScanResultNode *pNode, *pNextNode; |
| 1295 | tANI_U16 i; |
| 1296 | for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++) |
| 1297 | { |
| 1298 | if ((pNode = pMac->lim.gLimCachedLfrScanHashTable[i]) != NULL) |
| 1299 | { |
| 1300 | while (pNode) |
| 1301 | { |
| 1302 | pNextNode = pNode->next; |
| 1303 | |
| 1304 | // Delete the current node |
Bansidhar Gopalachari | 1273123 | 2013-07-11 10:56:36 +0530 | [diff] [blame] | 1305 | vos_mem_free(pNode); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1306 | |
| 1307 | pNode = pNextNode; |
| 1308 | } |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | pMac->lim.gLimSmeLfrScanResultLength = 0; |
| 1313 | } /****** end limDeleteCachedLfrScanResults() ******/ |
| 1314 | |
| 1315 | |
| 1316 | |
| 1317 | /** |
| 1318 | * limReInitLfrScanResults() |
| 1319 | * |
| 1320 | *FUNCTION: |
| 1321 | * This function is called delete exisiting scan results |
| 1322 | * and initialize the lfr scan hash table |
| 1323 | * |
| 1324 | *LOGIC: |
| 1325 | * |
| 1326 | *ASSUMPTIONS: |
| 1327 | * NA |
| 1328 | * |
| 1329 | *NOTE: |
| 1330 | * NA |
| 1331 | * |
| 1332 | * @param pMac - Pointer to Global MAC structure |
| 1333 | * @return None |
| 1334 | */ |
| 1335 | |
| 1336 | void |
| 1337 | limReInitLfrScanResults(tpAniSirGlobal pMac) |
| 1338 | { |
Rashmi Ramanna | 6c13a34 | 2014-01-07 11:44:07 +0530 | [diff] [blame] | 1339 | limLog(pMac, LOG1, FL("Re initialize lfr scan hash table.")); |
Varun Reddy Yeturu | d0a3f25 | 2013-04-15 21:58:13 -0700 | [diff] [blame] | 1340 | limDeleteCachedLfrScanResults(pMac); |
| 1341 | limInitLfrHashTable(pMac); |
| 1342 | |
| 1343 | // !!LAC - need to clear out the global scan result length |
| 1344 | // since the list was just purged from the hash table. |
| 1345 | pMac->lim.gLimMlmLfrScanResultLength = 0; |
| 1346 | |
| 1347 | } /****** end limReInitLfrScanResults() ******/ |
| 1348 | #endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD |