blob: afcbc31809c7e658d22dba9d8d354b322bbe1543 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * 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 Johnson295189b2012-06-20 16:38:30 -070029 * 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 Singhe3fa11f2014-05-13 11:11:10 +053046#include "vos_utils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070047
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
71tANI_U32
72limDeactivateMinChannelTimerDuringScan(tpAniSirGlobal pMac)
73{
Abhishek Singh01a19762015-09-03 11:07:19 +053074 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 Johnson295189b2012-06-20 16:38:30 -070078 {
79 /**
Abhishek Singh01a19762015-09-03 11:07:19 +053080 * Beacon/Probe Response is received during active scanning.
81 * Deactivate MIN channel timer if running.
82 */
83
Jeff Johnson295189b2012-06-20 16:38:30 -070084 limDeactivateAndChangeTimer(pMac,eLIM_MIN_CHANNEL_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -070085 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
86 == TX_TIMER_ERROR)
87 {
88 /// Could not activate max channel timer.
89 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -070090 limLog(pMac,LOGP, FL("could not activate max channel timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070091
92 limCompleteMlmScan(pMac, eSIR_SME_RESOURCES_UNAVAILABLE);
93 return TX_TIMER_ERROR;
94 }
95 }
96 return eSIR_SUCCESS;
97} /*** end limDeactivateMinChannelTimerDuringScan() ***/
98
99
100
101/**
102 * limCollectBssDescription()
103 *
104 *FUNCTION:
105 * This function is called during scan upon receiving
106 * Beacon/Probe Response frame to check if the received
107 * frame matches scan criteria, collect BSS description
108 * and add it to cached scan results.
109 *
110 *LOGIC:
111 *
112 *ASSUMPTIONS:
113 * NA
114 *
115 *NOTE:
116 * NA
117 *
118 * @param pMac - Pointer to Global MAC structure
119 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
120 * @param pRxPacketInfo - Pointer to Received frame's BD
121 * ---------if defined WLAN_FEATURE_VOWIFI------
122 * @param fScanning - flag to indicate if it is during scan.
123 * ---------------------------------------------
124 *
125 * @return None
126 */
127#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530128eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700129limCollectBssDescription(tpAniSirGlobal pMac,
130 tSirBssDescription *pBssDescr,
131 tpSirProbeRespBeacon pBPR,
132 tANI_U8 *pRxPacketInfo,
133 tANI_U8 fScanning)
134#else
Kiet Lam623403f2013-10-21 20:29:40 +0530135eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700136limCollectBssDescription(tpAniSirGlobal pMac,
137 tSirBssDescription *pBssDescr,
138 tpSirProbeRespBeacon pBPR,
139 tANI_U8 *pRxPacketInfo)
140#endif
141{
142 tANI_U8 *pBody;
143 tANI_U32 ieLen = 0;
144 tpSirMacMgmtHdr pHdr;
145 tANI_U8 channelNum;
146 tANI_U8 rxChannel;
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700147 tANI_U8 rfBand = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700148
149 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800150 VOS_ASSERT(WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) >= SIR_MAC_B_PR_SSID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) - SIR_MAC_B_PR_SSID_OFFSET;
152 rxChannel = WDA_GET_RX_CH(pRxPacketInfo);
153 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700154 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700155
Kiet Lam623403f2013-10-21 20:29:40 +0530156 /**
157 * Drop all the beacons and probe response without P2P IE during P2P search
158 */
159 if (NULL != pMac->lim.gpLimMlmScanReq && pMac->lim.gpLimMlmScanReq->p2pSearch)
160 {
161 if (NULL == limGetP2pIEPtr(pMac, (pBody + SIR_MAC_B_PR_SSID_OFFSET), ieLen))
162 {
163 limLog( pMac, LOG3, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHdr->bssId));
164 return eHAL_STATUS_FAILURE;
165 }
166 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700167
168 /**
169 * Length of BSS desription is without length of
170 * length itself and length of pointer
171 * that holds the next BSS description
172 */
173 pBssDescr->length = (tANI_U16)(
174 sizeof(tSirBssDescription) - sizeof(tANI_U16) -
175 sizeof(tANI_U32) + ieLen);
176
177 // Copy BSS Id
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530178 vos_mem_copy((tANI_U8 *) &pBssDescr->bssId,
179 (tANI_U8 *) pHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 sizeof(tSirMacAddr));
181
182 // Copy Timestamp, Beacon Interval and Capability Info
183 pBssDescr->scanSysTimeMsec = vos_timer_get_system_time();
184
185 pBssDescr->timeStamp[0] = pBPR->timeStamp[0];
186 pBssDescr->timeStamp[1] = pBPR->timeStamp[1];
187 pBssDescr->beaconInterval = pBPR->beaconInterval;
188 pBssDescr->capabilityInfo = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
189
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +0530190 if(!pBssDescr->beaconInterval )
191 {
192 limLog(pMac, LOGW,
193 FL("Beacon Interval is ZERO, making it to default 100 "
194 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->bssId));
195 pBssDescr->beaconInterval= 100;
196 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 /*
198 * There is a narrow window after Channel Switch msg is sent to HAL and before the AGC is shut
199 * down and beacons/Probe Rsps can trickle in and we may report the incorrect channel in 5Ghz
200 * band, so not relying on the 'last Scanned Channel' stored in LIM.
201 * Instead use the value returned by RXP in BD. This the the same value which HAL programs into
202 * RXP before every channel switch.
203 * Right now there is a problem in 5Ghz, where we are receiving beacons from a channel different from
204 * the currently scanned channel. so incorrect channel is reported to CSR and association does not happen.
205 * So for now we keep on looking for the channel info in the beacon (DSParamSet IE OR HT Info IE), and only if it
206 * is not present in the beacon, we go for the channel info present in RXP.
207 * 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.
208 * So The problem of incorrect channel reporting in 5Ghz will still remain for 11a devices.
209 */
210 pBssDescr->channelId = limGetChannelFromBeacon(pMac, pBPR);
211
212 if (pBssDescr->channelId == 0)
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700213 {
214 /* If the channel Id is not retrieved from Beacon, extract the channel from BD */
215 /* Unmapped the channel.This We have to do since we have done mapping in the hal to
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 overcome the limitation of RXBD of not able to accomodate the bigger channel number.*/
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700217 if ((!rfBand) || IS_5G_BAND(rfBand))
218 {
219 rxChannel = limUnmapChannel(rxChannel);
220 }
221 if (!rxChannel)
222 {
223 rxChannel = pMac->lim.gLimCurrentScanChannelId;
224 }
225 pBssDescr->channelId = rxChannel;
226 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700227
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530228 pBssDescr->channelIdSelf = pBssDescr->channelId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 //set the network type in bss description
230 channelNum = pBssDescr->channelId;
231 pBssDescr->nwType = limGetNwType(pMac, channelNum, SIR_MAC_MGMT_FRAME, pBPR);
232
233 pBssDescr->aniIndicator = pBPR->propIEinfo.aniIndicator;
234
235 // Copy RSSI & SINR from BD
236
237 PELOG4(limLog(pMac, LOG4, "***********BSS Description for BSSID:*********** ");
238 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pBssDescr->bssId, 6 );
239 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG4, (tANI_U8*)pRxPacketInfo, 36 );)
240
241 pBssDescr->rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo);
242
243 //SINR no longer reported by HW
244 pBssDescr->sinr = 0;
245
246 pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
247
248#if defined WLAN_FEATURE_VOWIFI
249 if( fScanning )
250 {
251 rrmGetStartTSF( pMac, pBssDescr->startTSF );
252 pBssDescr->parentTSF = WDA_GET_RX_TIMESTAMP(pRxPacketInfo);
253 }
254#endif
255
256#ifdef WLAN_FEATURE_VOWIFI_11R
257 // MobilityDomain
258 pBssDescr->mdie[0] = 0;
259 pBssDescr->mdie[1] = 0;
260 pBssDescr->mdie[2] = 0;
261 pBssDescr->mdiePresent = FALSE;
262 // If mdie is present in the probe resp we
263 // fill it in the bss description
264 if( pBPR->mdiePresent)
265 {
266 pBssDescr->mdiePresent = TRUE;
267 pBssDescr->mdie[0] = pBPR->mdie[0];
268 pBssDescr->mdie[1] = pBPR->mdie[1];
269 pBssDescr->mdie[2] = pBPR->mdie[2];
270 }
271#endif
272
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800273#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 pBssDescr->QBSSLoad_present = FALSE;
275 pBssDescr->QBSSLoad_avail = 0;
276 if( pBPR->QBSSLoad.present)
277 {
278 pBssDescr->QBSSLoad_present = TRUE;
279 pBssDescr->QBSSLoad_avail = pBPR->QBSSLoad.avail;
280 }
281#endif
282 // Copy IE fields
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530283 vos_mem_copy((tANI_U8 *) &pBssDescr->ieFields,
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 pBody + SIR_MAC_B_PR_SSID_OFFSET,
285 ieLen);
286
287 //sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGW, (tANI_U8 *) pBssDescr, pBssDescr->length + 2 );
288 limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700289 FL("Collected BSS Description for Channel(%1d), length(%u), aniIndicator(%d), IE Fields(%u)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 pBssDescr->channelId,
291 pBssDescr->length,
292 pBssDescr->aniIndicator,
293 ieLen );
294
Kiet Lam623403f2013-10-21 20:29:40 +0530295 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700296} /*** end limCollectBssDescription() ***/
297
298/**
299 * limIsScanRequestedSSID()
300 *
301 *FUNCTION:
302 * This function is called during scan upon receiving
303 * Beacon/Probe Response frame to check if the received
304 * SSID is present in the list of requested SSIDs in scan
305 *
306 *LOGIC:
307 *
308 *ASSUMPTIONS:
309 * NA
310 *
311 *NOTE:
312 * NA
313 *
314 * @param pMac - Pointer to Global MAC structure
315 * @param ssId - SSID Received in beacons/Probe responses that is compared against the
316 requeusted SSID in scan list
317 * ---------------------------------------------
318 *
319 * @return boolean - TRUE if SSID is present in requested list, FALSE otherwise
320 */
321
322tANI_BOOLEAN limIsScanRequestedSSID(tpAniSirGlobal pMac, tSirMacSSid *ssId)
323{
324 tANI_U8 i = 0;
325
326 for (i = 0; i < pMac->lim.gpLimMlmScanReq->numSsid; i++)
327 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530328 if ( eANI_BOOLEAN_TRUE == vos_mem_compare((tANI_U8 *) ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 (tANI_U8 *) &pMac->lim.gpLimMlmScanReq->ssId[i],
330 (tANI_U8) (pMac->lim.gpLimMlmScanReq->ssId[i].length + 1)))
331 {
332 return eANI_BOOLEAN_TRUE;
333 }
334 }
335 return eANI_BOOLEAN_FALSE;
336}
337
338/**
339 * limCheckAndAddBssDescription()
340 *
341 *FUNCTION:
342 * This function is called during scan upon receiving
343 * Beacon/Probe Response frame to check if the received
344 * frame matches scan criteria, collect BSS description
345 * and add it to cached scan results.
346 *
347 *LOGIC:
348 *
349 *ASSUMPTIONS:
350 * NA
351 *
352 *NOTE:
353 * NA
354 *
355 * @param pMac - Pointer to Global MAC structure
356 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
357 * @param pRxPacketInfo - Pointer to Received frame's BD
358 * @param fScanning - boolean to indicate whether the BSS is from current scan or just happen to receive a beacon
359 *
360 * @return None
361 */
362
363void
364limCheckAndAddBssDescription(tpAniSirGlobal pMac,
365 tpSirProbeRespBeacon pBPR,
366 tANI_U8 *pRxPacketInfo,
367 tANI_BOOLEAN fScanning,
368 tANI_U8 fProbeRsp)
369{
370 tLimScanResultNode *pBssDescr;
371 tANI_U32 frameLen, ieLen = 0;
372 tANI_U8 rxChannelInBeacon = 0;
373 eHalStatus status;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700374 tANI_U8 dontUpdateAll = 0;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700375 tANI_U8 rfBand = 0;
376 tANI_U8 rxChannelInBD = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700377
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 tSirMacAddr bssid = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
Agrawal Ashish9948e082014-07-17 13:48:37 +0530379 tSirMacAddr bssid_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 tANI_BOOLEAN fFound = FALSE;
381 tpSirMacDataHdr3a pHdr;
382
383 pHdr = WDA_GET_RX_MPDUHEADER3A((tANI_U8 *)pRxPacketInfo);
384
Agrawal Ashish9948e082014-07-17 13:48:37 +0530385 // Check For Null BSSID; Skip in case of P2P.
386 if (vos_mem_compare(bssid_zero, &pHdr->addr3, 6))
387 {
388 return ;
389 }
390
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 //Checking if scanning for a particular BSSID
392 if ((fScanning) && (pMac->lim.gpLimMlmScanReq))
393 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530394 fFound = vos_mem_compare(pHdr->addr3, &pMac->lim.gpLimMlmScanReq->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 if (!fFound)
396 {
397 if ((pMac->lim.gpLimMlmScanReq->p2pSearch) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530398 (vos_mem_compare(pBPR->P2PProbeRes.P2PDeviceInfo.P2PDeviceAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -0700399 &pMac->lim.gpLimMlmScanReq->bssId, 6)))
400 {
401 fFound = eANI_BOOLEAN_TRUE;
402 }
403 }
404 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700405
406 /**
407 * Compare SSID with the one sent in
408 * Probe Request frame, if any.
409 * If they don't match, ignore the
410 * Beacon frame.
411 * pMac->lim.gLimMlmScanReq->ssId.length == 0
412 * indicates Broadcast SSID.
413 * When gLimReturnAfterFirstMatch is set, it means the scan has to match
414 * a SSID (if it is also set). Ignore the other BSS in that case.
415 */
416
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700417#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
418 if (!(WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo)))
419 {
420#endif
421 if ((pMac->lim.gpLimMlmScanReq) &&
422 (((fScanning) &&
423 ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) &&
424 (pMac->lim.gpLimMlmScanReq->numSsid) &&
425 !limIsScanRequestedSSID(pMac, &pBPR->ssId)) ||
426 (!fFound && (pMac->lim.gpLimMlmScanReq &&
427 pMac->lim.gpLimMlmScanReq->bssId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530428 !vos_mem_compare(bssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700429 &pMac->lim.gpLimMlmScanReq->bssId, 6))))
Jeff Johnson295189b2012-06-20 16:38:30 -0700430 {
431 /**
432 * Received SSID does not match with
433 * the one we're scanning for.
434 * Ignore received Beacon frame
435 */
436
437 return;
438 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700439#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
440 }
441#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700442
443 /* There is no point in caching & reporting the scan results for APs
444 * which are in the process of switching the channel. So, we are not
445 * caching the scan results for APs which are adverzing the channel-switch
446 * element in their beacons and probe responses.
447 */
448 if(pBPR->channelSwitchPresent)
449 {
450 return;
451 }
452
453 /* If beacon/probe resp DS param channel does not match with
454 * RX BD channel then don't save the results. It might be a beacon
455 * from another channel heard as noise on the current scanning channel
456 */
457
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700458 if ((pBPR->dsParamsPresent) || (pBPR->HTInfo.present))
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 {
460 /* This means that we are in 2.4GHz mode or 5GHz 11n mode */
461 rxChannelInBeacon = limGetChannelFromBeacon(pMac, pBPR);
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700462 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
463 rxChannelInBD = WDA_GET_RX_CH(pRxPacketInfo);
464
465 if ((!rfBand) || IS_5G_BAND(rfBand))
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 {
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700467 rxChannelInBD = limUnmapChannel(rxChannelInBD);
468 }
469
470 if(rxChannelInBD != rxChannelInBeacon)
471 {
472 /* BCAST Frame, if CH do not match, Drop */
473 if(WDA_IS_RX_BCAST(pRxPacketInfo))
474 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700475 limLog(pMac, LOG3, FL("Beacon/Probe Rsp dropped. Channel in BD %d. "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700476 "Channel in beacon" " %d"),
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700477 WDA_GET_RX_CH(pRxPacketInfo),limGetChannelFromBeacon(pMac, pBPR));
478 return;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700479 }
480 /* Unit cast frame, Probe RSP, do not drop */
481 else
482 {
483 dontUpdateAll = 1;
484 limLog(pMac, LOG3, FL("SSID %s, CH in ProbeRsp %d, CH in BD %d, miss-match, Do Not Drop"),
485 pBPR->ssId.ssId,
486 rxChannelInBeacon,
487 WDA_GET_RX_CH(pRxPacketInfo));
488 WDA_GET_RX_CH(pRxPacketInfo) = rxChannelInBeacon;
489 }
490 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 }
492
493 /**
494 * Allocate buffer to hold BSS description from
495 * received Beacon frame.
496 * Include size of fixed fields and IEs length
497 */
498
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800499 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
500 if (ieLen <= SIR_MAC_B_PR_SSID_OFFSET)
501 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700502 limLog(pMac, LOGP,
503 FL("RX packet has invalid length %d"), ieLen);
504 return;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800505 }
506
507 ieLen -= SIR_MAC_B_PR_SSID_OFFSET;
508
509 frameLen = sizeof(tLimScanResultNode) + ieLen - sizeof(tANI_U32); //Sizeof(tANI_U32) is for ieFields[1]
Jeff Johnson295189b2012-06-20 16:38:30 -0700510
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530511 pBssDescr = vos_mem_malloc(frameLen);
512 if ( NULL == pBssDescr )
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 {
514 // Log error
515 limLog(pMac, LOGP,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530516 FL("call for AllocateMemory failed for storing BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700517
518 return;
519 }
520
Padma, Santhosh Kumarf21a0d92015-11-02 12:41:06 +0530521 vos_mem_zero(pBssDescr, frameLen);
522
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 // In scan state, store scan result.
524#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530525 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 pBPR, pRxPacketInfo, fScanning);
Kiet Lam623403f2013-10-21 20:29:40 +0530527 if (eHAL_STATUS_SUCCESS != status)
528 {
529 goto last;
530 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700531#else
Kiet Lam623403f2013-10-21 20:29:40 +0530532 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 pBPR, pRxPacketInfo);
Kiet Lam623403f2013-10-21 20:29:40 +0530534 if (eHAL_STATUS_SUCCESS != status)
535 {
536 goto last;
537 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 pBssDescr->bssDescription.fProbeRsp = fProbeRsp;
540
541 pBssDescr->next = NULL;
542
543 /**
544 * Depending on whether to store unique or all
545 * scan results, pass hash update/add parameter
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700546 * For LFR candidates just add them on it's own cache
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 */
548
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700549#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
550 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
551 {
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530552 limLog(pMac, LOG1, FL(" pHdr->addr1:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800553 MAC_ADDR_ARRAY(pHdr->addr1));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530554 limLog(pMac, LOG1, FL(" pHdr->addr2:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800555 MAC_ADDR_ARRAY(pHdr->addr2));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530556 limLog(pMac, LOG1, FL(" pHdr->addr3:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800557 MAC_ADDR_ARRAY(pHdr->addr3));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530558 limLog( pMac, LOG1, FL("Save this entry in LFR cache"));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700559 status = limLookupNaddLfrHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
560 }
561 else
562#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 //If it is not scanning, only save unique results
564 if (pMac->lim.gLimReturnUniqueResults || (!fScanning))
565 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700566 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_UPDATE, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 }
568 else
569 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700570 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 }
572
573 if(fScanning)
574 {
575 if ((pBssDescr->bssDescription.channelId <= 14) &&
576 (pMac->lim.gLimReturnAfterFirstMatch & 0x40) &&
577 pBPR->countryInfoPresent)
578 pMac->lim.gLim24Band11dScanDone = 1;
579
580 if ((pBssDescr->bssDescription.channelId > 14) &&
581 (pMac->lim.gLimReturnAfterFirstMatch & 0x80) &&
582 pBPR->countryInfoPresent)
583 pMac->lim.gLim50Band11dScanDone = 1;
584
585 if ( ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) ||
586 ( pMac->lim.gLim24Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x40 ) ) ||
Gopichand Nakkala48b4d7e2013-03-06 23:34:16 +0530587 ( pMac->lim.gLim50Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x80 ) ) ||
588 fFound )
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 {
590 /**
591 * Stop scanning and return the BSS description(s)
592 * collected so far.
593 */
594 limLog(pMac,
595 LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700596 FL("Completed scan: 24Band11dScan = %d, 50Band11dScan = %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700597 pMac->lim.gLim24Band11dScanDone,
598 pMac->lim.gLim50Band11dScanDone);
599
600 //Need to disable the timers. If they fire, they will send END_SCAN
601 //while we already send FINISH_SCAN here. This may mess up the gLimHalScanState
602 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
603 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
604 //Set the resume channel to Any valid channel (invalid).
605 //This will instruct HAL to set it to any previous valid channel.
606 peSetResumeChannel(pMac, 0, 0);
607 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
608 //limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
609 }
610 }//(eANI_BOOLEAN_TRUE == fScanning)
611
Kiet Lam623403f2013-10-21 20:29:40 +0530612last:
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 if( eHAL_STATUS_SUCCESS != status )
614 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530615 vos_mem_free( pBssDescr );
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 }
Kiet Lam623403f2013-10-21 20:29:40 +0530617 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700618} /****** end limCheckAndAddBssDescription() ******/
619
620
621
622/**
623 * limScanHashFunction()
624 *
625 *FUNCTION:
626 * This function is called during scan hash entry operations
627 *
628 *LOGIC:
629 *
630 *ASSUMPTIONS:
631 * NA
632 *
633 *NOTE:
634 * NA
635 *
636 * @param bssId - Received BSSid
637 *
638 * @return Hash index
639 */
640
641tANI_U8
642limScanHashFunction(tSirMacAddr bssId)
643{
644 tANI_U16 i, hash = 0;
645
646 for (i = 0; i < sizeof(tSirMacAddr); i++)
647 hash += bssId[i];
648
649 return hash % LIM_MAX_NUM_OF_SCAN_RESULTS;
650} /****** end limScanHashFunction() ******/
651
652
653
654/**
655 * limInitHashTable()
656 *
657 *FUNCTION:
658 * This function is called upon receiving SME_START_REQ
659 * to initialize global cached scan hash table
660 *
661 *LOGIC:
662 *
663 *ASSUMPTIONS:
664 * NA
665 *
666 *NOTE:
667 * NA
668 *
669 * @param pMac - Pointer to Global MAC structure
670 * @return None
671 */
672
673void
674limInitHashTable(tpAniSirGlobal pMac)
675{
676 tANI_U16 i;
677 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
678 pMac->lim.gLimCachedScanHashTable[i] = NULL;
679} /****** end limInitHashTable() ******/
680
681
682
683/**
684 * limLookupNaddHashEntry()
685 *
686 *FUNCTION:
687 * This function is called upon receiving a Beacon or
688 * Probe Response frame during scan phase to store
689 * received BSS description into scan result hash table.
690 *
691 *LOGIC:
692 *
693 *ASSUMPTIONS:
694 * NA
695 *
696 *NOTE:
697 * NA
698 *
699 * @param pMac - Pointer to Global MAC structure
700 * @param pBssDescr - Pointer to BSS description to be
701 * added to the scan result hash table.
702 * @param action - Indicates action to be performed
703 * when same BSS description is found. This is
704 * dependent on whether unique scan result to
705 * be stored or not.
706 *
707 * @return None
708 */
709
710eHalStatus
711limLookupNaddHashEntry(tpAniSirGlobal pMac,
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700712 tLimScanResultNode *pBssDescr, tANI_U8 action,
713 tANI_U8 dontUpdateAll)
Jeff Johnson295189b2012-06-20 16:38:30 -0700714{
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700715 tANI_U8 index, ssidLen = 0;
716 tANI_U8 found = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 tLimScanResultNode *ptemp, *pprev;
718 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
719 int idx, len;
720 tANI_U8 *pbIe;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700721 tANI_S8 rssi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
723 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
724 ptemp = pMac->lim.gLimCachedScanHashTable[index];
725
726 //ieFields start with TLV of SSID IE
727 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
728 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
729
730 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
731 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700732 //For infrastructure, check BSSID and SSID. For IBSS, check more
Jeff Johnson295189b2012-06-20 16:38:30 -0700733 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530734 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
735 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 (tANI_U8 *) ptemp->bssDescription.bssId,
737 sizeof(tSirMacAddr))) && //matching BSSID
Abhishek Singhe3fa11f2014-05-13 11:11:10 +0530738 // matching band to update new channel info
739 (vos_chan_to_band(pBssDescr->bssDescription.channelId) ==
740 vos_chan_to_band(ptemp->bssDescription.channelId)) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530741 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
743 (tANI_U8) (ssidLen + 1)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700744 ((pSirCapTemp->ess) || //we are done for infrastructure
745 //For IBSS, nwType and channelId
746 (((pBssDescr->bssDescription.nwType ==
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 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 Koyyalamudi15865592012-09-28 15:55:37 -0700755 if(dontUpdateAll)
756 {
757 rssi = ptemp->bssDescription.rssi;
758 }
759
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
761 {
762 //We get a different, save the old frame WSC IE if it is there
763 idx = 0;
764 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
765 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
766 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
767 //Save WPS IE if it exists
768 pBssDescr->bssDescription.WscIeLen = 0;
769 while(idx < len)
770 {
771 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
772 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
773 {
774 //Found it
775 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
776 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530777 vos_mem_copy(pBssDescr->bssDescription.WscIeProbeRsp,
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 pbIe, pbIe[1] + 2);
779 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
780 }
781 break;
782 }
783 idx += pbIe[1] + 2;
784 pbIe += pbIe[1] + 2;
785 }
786 }
787
788
789 if(NULL != pMac->lim.gpLimMlmScanReq)
790 {
791 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
792 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
793 &pBssDescr->bssDescription.ieFields + 1))))
794 return eHAL_STATUS_FAILURE;
795 }
796
797 // Delete this entry
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700798 if (ptemp == pMac->lim.gLimCachedScanHashTable[index])
799 pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700800 else
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700801 pprev->next = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700802
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700803 pMac->lim.gLimMlmScanResultLength -=
804 ptemp->bssDescription.length + sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -0700805
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530806 vos_mem_free(ptemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 }
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700808 found = true;
809 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 }
811 }
812
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700813 //for now, only rssi, we can add more if needed
Madan Mohan Koyyalamudi3e9f2022012-12-04 16:34:19 -0800814 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700815 {
816 pBssDescr->bssDescription.rssi = rssi;
817 }
818
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 // Add this BSS description at same index
820 if (pprev == pMac->lim.gLimCachedScanHashTable[index])
821 {
822 pBssDescr->next = pMac->lim.gLimCachedScanHashTable[index];
823 pMac->lim.gLimCachedScanHashTable[index] = pBssDescr;
824 }
825 else
826 {
827 pBssDescr->next = pprev->next;
828 pprev->next = pBssDescr;
829 }
830 pMac->lim.gLimMlmScanResultLength +=
831 pBssDescr->bssDescription.length + sizeof(tANI_U16);
832
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700833 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 pBssDescr->bssDescription.length,
835 pMac->lim.gLimMlmScanResultLength);
836 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
837
838 // Send new BSS found indication to HDD if CFG option is set
839 if (!found) limSendSmeNeighborBssInd(pMac, pBssDescr);
840
841 //
842 // TODO: IF applicable, do we need to send:
843 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
844 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
845 //
846 return eHAL_STATUS_SUCCESS;
847}
848
849
850
851/**
852 * limDeleteHashEntry()
853 *
854 *FUNCTION:
855 * This function is called upon to delete
856 * a BSS description from scan result hash table.
857 *
858 *LOGIC:
859 *
860 *ASSUMPTIONS:
861 * NA
862 *
863 *NOTE:
864 * Yet to find the utility of the function
865 *
866 * @param pBssDescr - Pointer to BSS description to be
867 * deleted from the scan result hash table.
868 *
869 * @return None
870 */
871
872void limDeleteHashEntry(tLimScanResultNode *pBssDescr)
873{
874} /****** end limDeleteHashEntry() ******/
875
876
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700877#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
878/**
879 * limInitLfrHashTable()
880 *
881 *FUNCTION:
882 * This function is called upon receiving SME_START_REQ
883 * to initialize global cached Lfr scan hash table
884 *
885 *LOGIC:
886 *
887 *ASSUMPTIONS:
888 * NA
889 *
890 *NOTE:
891 * NA
892 *
893 * @param pMac - Pointer to Global MAC structure
894 * @return None
895 */
896
897void
898limInitLfrHashTable(tpAniSirGlobal pMac)
899{
900 tANI_U16 i;
901 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
902 pMac->lim.gLimCachedLfrScanHashTable[i] = NULL;
903} /****** end limInitLfrHashTable() ******/
904
905
906
907/**
908 * limLookupNaddLfrHashEntry()
909 *
910 *FUNCTION:
911 * This function is called upon receiving a Beacon or
912 * Probe Response frame during Lfr scan phase from FW to store
913 * received BSS description into Lfr scan result hash table.
914 *
915 *LOGIC:
916 *
917 *ASSUMPTIONS:
918 * NA
919 *
920 *NOTE:
921 * NA
922 *
923 * @param pMac - Pointer to Global MAC structure
924 * @param pBssDescr - Pointer to BSS description to be
925 * added to the Lfr scan result hash table.
926 * @param action - Indicates action to be performed
927 * when same BSS description is found. This is
928 * dependent on whether unique scan result to
929 * be stored or not.
930 *
931 * @return None
932 */
933
934eHalStatus
935limLookupNaddLfrHashEntry(tpAniSirGlobal pMac,
936 tLimScanResultNode *pBssDescr, tANI_U8 action,
937 tANI_U8 dontUpdateAll)
938{
939 tANI_U8 index, ssidLen = 0;
940 tLimScanResultNode *ptemp, *pprev;
941 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
942 int idx, len;
943 tANI_U8 *pbIe;
944 tANI_S8 rssi = 0;
945
946 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
947 ptemp = pMac->lim.gLimCachedLfrScanHashTable[index];
948
949 //ieFields start with TLV of SSID IE
950 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
951 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
952
953 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
954 {
955 //For infrastructure, check BSSID and SSID. For IBSS, check more
956 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530957 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
958 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700959 (tANI_U8 *) ptemp->bssDescription.bssId,
960 sizeof(tSirMacAddr))) && //matching BSSID
961 (pBssDescr->bssDescription.channelId ==
962 ptemp->bssDescription.channelId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530963 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700964 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
965 (tANI_U8) (ssidLen + 1)) &&
966 ((pSirCapTemp->ess) || //we are done for infrastructure
967 //For IBSS, nwType and channelId
968 (((pBssDescr->bssDescription.nwType ==
969 ptemp->bssDescription.nwType) &&
970 (pBssDescr->bssDescription.channelId ==
971 ptemp->bssDescription.channelId))))
972 )
973 {
974 // Found the same BSS description
975 if (action == LIM_HASH_UPDATE)
976 {
977 if(dontUpdateAll)
978 {
979 rssi = ptemp->bssDescription.rssi;
980 }
981
982 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
983 {
984 //We get a different, save the old frame WSC IE if it is there
985 idx = 0;
986 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
987 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
988 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
989 //Save WPS IE if it exists
990 pBssDescr->bssDescription.WscIeLen = 0;
991 while(idx < len)
992 {
993 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
994 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) &&
995 (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
996 {
997 //Found it
998 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
999 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301000 vos_mem_copy( pBssDescr->bssDescription.WscIeProbeRsp,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001001 pbIe, pbIe[1] + 2);
1002 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
1003 }
1004 break;
1005 }
1006 idx += pbIe[1] + 2;
1007 pbIe += pbIe[1] + 2;
1008 }
1009 }
1010
1011
1012 if(NULL != pMac->lim.gpLimMlmScanReq)
1013 {
1014 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
1015 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
1016 &pBssDescr->bssDescription.ieFields + 1))))
1017 return eHAL_STATUS_FAILURE;
1018 }
1019
1020 // Delete this entry
1021 if (ptemp == pMac->lim.gLimCachedLfrScanHashTable[index])
1022 pprev = pMac->lim.gLimCachedLfrScanHashTable[index] = ptemp->next;
1023 else
1024 pprev->next = ptemp->next;
1025
1026 pMac->lim.gLimMlmLfrScanResultLength -=
1027 ptemp->bssDescription.length + sizeof(tANI_U16);
1028
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301029 vos_mem_free(ptemp);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001030 }
1031 break;
1032 }
1033 }
1034
1035 //for now, only rssi, we can add more if needed
1036 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
1037 {
1038 pBssDescr->bssDescription.rssi = rssi;
1039 }
1040
1041 // Add this BSS description at same index
1042 if (pprev == pMac->lim.gLimCachedLfrScanHashTable[index])
1043 {
1044 pBssDescr->next = pMac->lim.gLimCachedLfrScanHashTable[index];
1045 pMac->lim.gLimCachedLfrScanHashTable[index] = pBssDescr;
1046 }
1047 else
1048 {
1049 pBssDescr->next = pprev->next;
1050 pprev->next = pBssDescr;
1051 }
1052 pMac->lim.gLimMlmLfrScanResultLength +=
1053 pBssDescr->bssDescription.length + sizeof(tANI_U16);
1054
1055 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id\n"),
1056 pBssDescr->bssDescription.length,
1057 pMac->lim.gLimMlmLfrScanResultLength);
1058 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
1059
1060 //
1061 // TODO: IF applicable, do we need to send:
1062 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
1063 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
1064 //
1065 return eHAL_STATUS_SUCCESS;
1066}
1067
1068
1069
1070/**
1071 * limDeleteLfrHashEntry()
1072 *
1073 *FUNCTION:
1074 * This function is called upon to delete
1075 * a BSS description from LFR scan result hash table.
1076 *
1077 *LOGIC:
1078 *
1079 *ASSUMPTIONS:
1080 * NA
1081 *
1082 *NOTE:
1083 * Yet to find the utility of the function
1084 *
1085 * @param pBssDescr - Pointer to BSS description to be
1086 * deleted from the LFR scan result hash table.
1087 *
1088 * @return None
1089 */
1090
1091void limDeleteLfrHashEntry(tLimScanResultNode *pBssDescr)
1092{
1093} /****** end limDeleteLfrHashEntry() ******/
1094
1095#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001096
1097/**
1098 * limCopyScanResult()
1099 *
1100 *FUNCTION:
1101 * This function is called by limProcessSmeMessages() while
1102 * sending SME_SCAN_RSP with scan result to HDD.
1103 *
1104 *LOGIC:
1105 * This function traverses the scan list stored in scan hash table
1106 *
1107 *ASSUMPTIONS:
1108 * NA
1109 *
1110 *NOTE:
1111 * NA
1112 *
1113 * @param pMac - Pointer to Global MAC structure
1114 * @param pDest - Destination pointer
1115 *
1116 * @return None
1117 */
1118
1119void
1120limCopyScanResult(tpAniSirGlobal pMac, tANI_U8 *pDest)
1121{
1122 tLimScanResultNode *ptemp;
1123 tANI_U16 i;
1124 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1125 {
1126 if ((ptemp = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1127 {
1128 while(ptemp)
1129 {
1130 /// Copy entire BSS description including length
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301131 vos_mem_copy( pDest,
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 (tANI_U8 *) &ptemp->bssDescription,
1133 ptemp->bssDescription.length + 2);
1134 pDest += ptemp->bssDescription.length + 2;
1135 ptemp = ptemp->next;
1136 }
1137 }
1138 }
1139} /****** end limCopyScanResult() ******/
1140
1141
1142
1143/**
1144 * limDeleteCachedScanResults()
1145 *
1146 *FUNCTION:
1147 * This function is called by limProcessSmeMessages() upon receiving
1148 * SME_SCAN_REQ with fresh scan result flag set.
1149 *
1150 *LOGIC:
1151 * This function traverses the scan list stored in scan hash table
1152 * and deletes the entries if any
1153 *
1154 *ASSUMPTIONS:
1155 * NA
1156 *
1157 *NOTE:
1158 * NA
1159 *
1160 * @param pMac - Pointer to Global MAC structure
1161 * @return None
1162 */
1163
1164void
1165limDeleteCachedScanResults(tpAniSirGlobal pMac)
1166{
1167 tLimScanResultNode *pNode, *pNextNode;
1168 tANI_U16 i;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301169
Jeff Johnson295189b2012-06-20 16:38:30 -07001170 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1171 {
1172 if ((pNode = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1173 {
1174 while (pNode)
1175 {
1176 pNextNode = pNode->next;
1177
1178 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301179 vos_mem_free(pNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001180
1181 pNode = pNextNode;
1182 }
1183 }
1184 }
1185
1186 pMac->lim.gLimSmeScanResultLength = 0;
1187} /****** end limDeleteCachedScanResults() ******/
1188
1189
1190
1191/**
1192 * limReInitScanResults()
1193 *
1194 *FUNCTION:
1195 * This function is called delete exisiting scan results
1196 * and initialize the scan hash table
1197 *
1198 *LOGIC:
1199 *
1200 *ASSUMPTIONS:
1201 * NA
1202 *
1203 *NOTE:
1204 * NA
1205 *
1206 * @param pMac - Pointer to Global MAC structure
1207 * @return None
1208 */
1209
1210void
1211limReInitScanResults(tpAniSirGlobal pMac)
1212{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301213 limLog(pMac, LOG1, FL("Re initialize scan hash table."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 limDeleteCachedScanResults(pMac);
1215 limInitHashTable(pMac);
1216
1217 // !!LAC - need to clear out the global scan result length
1218 // since the list was just purged from the hash table.
1219 pMac->lim.gLimMlmScanResultLength = 0;
1220
1221} /****** end limReInitScanResults() ******/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001222#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1223/**
1224 * limDeleteCachedLfrScanResults()
1225 *
1226 *FUNCTION:
1227 * This function is called by limProcessSmeMessages() upon receiving
1228 * SME_SCAN_REQ with flush scan result flag set for LFR.
1229 *
1230 *LOGIC:
1231 * This function traverses the scan list stored in lfr scan hash
1232 * table and deletes the entries if any
1233 *
1234 *ASSUMPTIONS:
1235 * NA
1236 *
1237 *NOTE:
1238 * NA
1239 *
1240 * @param pMac - Pointer to Global MAC structure
1241 * @return None
1242 */
1243
1244void
1245limDeleteCachedLfrScanResults(tpAniSirGlobal pMac)
1246{
1247 tLimScanResultNode *pNode, *pNextNode;
1248 tANI_U16 i;
1249 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1250 {
1251 if ((pNode = pMac->lim.gLimCachedLfrScanHashTable[i]) != NULL)
1252 {
1253 while (pNode)
1254 {
1255 pNextNode = pNode->next;
1256
1257 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301258 vos_mem_free(pNode);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001259
1260 pNode = pNextNode;
1261 }
1262 }
1263 }
1264
1265 pMac->lim.gLimSmeLfrScanResultLength = 0;
1266} /****** end limDeleteCachedLfrScanResults() ******/
1267
1268
1269
1270/**
1271 * limReInitLfrScanResults()
1272 *
1273 *FUNCTION:
1274 * This function is called delete exisiting scan results
1275 * and initialize the lfr scan hash table
1276 *
1277 *LOGIC:
1278 *
1279 *ASSUMPTIONS:
1280 * NA
1281 *
1282 *NOTE:
1283 * NA
1284 *
1285 * @param pMac - Pointer to Global MAC structure
1286 * @return None
1287 */
1288
1289void
1290limReInitLfrScanResults(tpAniSirGlobal pMac)
1291{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301292 limLog(pMac, LOG1, FL("Re initialize lfr scan hash table."));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001293 limDeleteCachedLfrScanResults(pMac);
1294 limInitLfrHashTable(pMac);
1295
1296 // !!LAC - need to clear out the global scan result length
1297 // since the list was just purged from the hash table.
1298 pMac->lim.gLimMlmLfrScanResultLength = 0;
1299
1300} /****** end limReInitLfrScanResults() ******/
1301#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD