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