blob: 875b28cadcd855ca27d8394cea8fe840acfd4397 [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
521 // In scan state, store scan result.
522#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530523 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 pBPR, pRxPacketInfo, fScanning);
Kiet Lam623403f2013-10-21 20:29:40 +0530525 if (eHAL_STATUS_SUCCESS != status)
526 {
527 goto last;
528 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700529#else
Kiet Lam623403f2013-10-21 20:29:40 +0530530 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 pBPR, pRxPacketInfo);
Kiet Lam623403f2013-10-21 20:29:40 +0530532 if (eHAL_STATUS_SUCCESS != status)
533 {
534 goto last;
535 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700536#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 pBssDescr->bssDescription.fProbeRsp = fProbeRsp;
538
539 pBssDescr->next = NULL;
540
541 /**
542 * Depending on whether to store unique or all
543 * scan results, pass hash update/add parameter
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700544 * For LFR candidates just add them on it's own cache
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 */
546
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700547#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
548 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
549 {
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530550 limLog(pMac, LOG1, FL(" pHdr->addr1:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800551 MAC_ADDR_ARRAY(pHdr->addr1));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530552 limLog(pMac, LOG1, FL(" pHdr->addr2:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800553 MAC_ADDR_ARRAY(pHdr->addr2));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530554 limLog(pMac, LOG1, FL(" pHdr->addr3:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800555 MAC_ADDR_ARRAY(pHdr->addr3));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530556 limLog( pMac, LOG1, FL("Save this entry in LFR cache"));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700557 status = limLookupNaddLfrHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
558 }
559 else
560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 //If it is not scanning, only save unique results
562 if (pMac->lim.gLimReturnUniqueResults || (!fScanning))
563 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700564 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_UPDATE, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 }
566 else
567 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700568 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 }
570
571 if(fScanning)
572 {
573 if ((pBssDescr->bssDescription.channelId <= 14) &&
574 (pMac->lim.gLimReturnAfterFirstMatch & 0x40) &&
575 pBPR->countryInfoPresent)
576 pMac->lim.gLim24Band11dScanDone = 1;
577
578 if ((pBssDescr->bssDescription.channelId > 14) &&
579 (pMac->lim.gLimReturnAfterFirstMatch & 0x80) &&
580 pBPR->countryInfoPresent)
581 pMac->lim.gLim50Band11dScanDone = 1;
582
583 if ( ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) ||
584 ( pMac->lim.gLim24Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x40 ) ) ||
Gopichand Nakkala48b4d7e2013-03-06 23:34:16 +0530585 ( pMac->lim.gLim50Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x80 ) ) ||
586 fFound )
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 {
588 /**
589 * Stop scanning and return the BSS description(s)
590 * collected so far.
591 */
592 limLog(pMac,
593 LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700594 FL("Completed scan: 24Band11dScan = %d, 50Band11dScan = %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 pMac->lim.gLim24Band11dScanDone,
596 pMac->lim.gLim50Band11dScanDone);
597
598 //Need to disable the timers. If they fire, they will send END_SCAN
599 //while we already send FINISH_SCAN here. This may mess up the gLimHalScanState
600 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
601 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
602 //Set the resume channel to Any valid channel (invalid).
603 //This will instruct HAL to set it to any previous valid channel.
604 peSetResumeChannel(pMac, 0, 0);
605 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
606 //limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
607 }
608 }//(eANI_BOOLEAN_TRUE == fScanning)
609
Kiet Lam623403f2013-10-21 20:29:40 +0530610last:
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 if( eHAL_STATUS_SUCCESS != status )
612 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530613 vos_mem_free( pBssDescr );
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 }
Kiet Lam623403f2013-10-21 20:29:40 +0530615 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700616} /****** end limCheckAndAddBssDescription() ******/
617
618
619
620/**
621 * limScanHashFunction()
622 *
623 *FUNCTION:
624 * This function is called during scan hash entry operations
625 *
626 *LOGIC:
627 *
628 *ASSUMPTIONS:
629 * NA
630 *
631 *NOTE:
632 * NA
633 *
634 * @param bssId - Received BSSid
635 *
636 * @return Hash index
637 */
638
639tANI_U8
640limScanHashFunction(tSirMacAddr bssId)
641{
642 tANI_U16 i, hash = 0;
643
644 for (i = 0; i < sizeof(tSirMacAddr); i++)
645 hash += bssId[i];
646
647 return hash % LIM_MAX_NUM_OF_SCAN_RESULTS;
648} /****** end limScanHashFunction() ******/
649
650
651
652/**
653 * limInitHashTable()
654 *
655 *FUNCTION:
656 * This function is called upon receiving SME_START_REQ
657 * to initialize global cached scan hash table
658 *
659 *LOGIC:
660 *
661 *ASSUMPTIONS:
662 * NA
663 *
664 *NOTE:
665 * NA
666 *
667 * @param pMac - Pointer to Global MAC structure
668 * @return None
669 */
670
671void
672limInitHashTable(tpAniSirGlobal pMac)
673{
674 tANI_U16 i;
675 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
676 pMac->lim.gLimCachedScanHashTable[i] = NULL;
677} /****** end limInitHashTable() ******/
678
679
680
681/**
682 * limLookupNaddHashEntry()
683 *
684 *FUNCTION:
685 * This function is called upon receiving a Beacon or
686 * Probe Response frame during scan phase to store
687 * received BSS description into scan result hash table.
688 *
689 *LOGIC:
690 *
691 *ASSUMPTIONS:
692 * NA
693 *
694 *NOTE:
695 * NA
696 *
697 * @param pMac - Pointer to Global MAC structure
698 * @param pBssDescr - Pointer to BSS description to be
699 * added to the scan result hash table.
700 * @param action - Indicates action to be performed
701 * when same BSS description is found. This is
702 * dependent on whether unique scan result to
703 * be stored or not.
704 *
705 * @return None
706 */
707
708eHalStatus
709limLookupNaddHashEntry(tpAniSirGlobal pMac,
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700710 tLimScanResultNode *pBssDescr, tANI_U8 action,
711 tANI_U8 dontUpdateAll)
Jeff Johnson295189b2012-06-20 16:38:30 -0700712{
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700713 tANI_U8 index, ssidLen = 0;
714 tANI_U8 found = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 tLimScanResultNode *ptemp, *pprev;
716 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
717 int idx, len;
718 tANI_U8 *pbIe;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700719 tANI_S8 rssi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700720
721 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
722 ptemp = pMac->lim.gLimCachedScanHashTable[index];
723
724 //ieFields start with TLV of SSID IE
725 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
726 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
727
728 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
729 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700730 //For infrastructure, check BSSID and SSID. For IBSS, check more
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530732 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
733 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 (tANI_U8 *) ptemp->bssDescription.bssId,
735 sizeof(tSirMacAddr))) && //matching BSSID
Abhishek Singhe3fa11f2014-05-13 11:11:10 +0530736 // matching band to update new channel info
737 (vos_chan_to_band(pBssDescr->bssDescription.channelId) ==
738 vos_chan_to_band(ptemp->bssDescription.channelId)) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530739 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
741 (tANI_U8) (ssidLen + 1)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700742 ((pSirCapTemp->ess) || //we are done for infrastructure
743 //For IBSS, nwType and channelId
744 (((pBssDescr->bssDescription.nwType ==
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 ptemp->bssDescription.nwType) &&
746 (pBssDescr->bssDescription.channelId ==
747 ptemp->bssDescription.channelId))))
748 )
749 {
750 // Found the same BSS description
751 if (action == LIM_HASH_UPDATE)
752 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700753 if(dontUpdateAll)
754 {
755 rssi = ptemp->bssDescription.rssi;
756 }
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
759 {
760 //We get a different, save the old frame WSC IE if it is there
761 idx = 0;
762 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
763 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
764 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
765 //Save WPS IE if it exists
766 pBssDescr->bssDescription.WscIeLen = 0;
767 while(idx < len)
768 {
769 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
770 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
771 {
772 //Found it
773 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
774 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530775 vos_mem_copy(pBssDescr->bssDescription.WscIeProbeRsp,
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 pbIe, pbIe[1] + 2);
777 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
778 }
779 break;
780 }
781 idx += pbIe[1] + 2;
782 pbIe += pbIe[1] + 2;
783 }
784 }
785
786
787 if(NULL != pMac->lim.gpLimMlmScanReq)
788 {
789 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
790 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
791 &pBssDescr->bssDescription.ieFields + 1))))
792 return eHAL_STATUS_FAILURE;
793 }
794
795 // Delete this entry
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700796 if (ptemp == pMac->lim.gLimCachedScanHashTable[index])
797 pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 else
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700799 pprev->next = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700800
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700801 pMac->lim.gLimMlmScanResultLength -=
802 ptemp->bssDescription.length + sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -0700803
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530804 vos_mem_free(ptemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 }
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700806 found = true;
807 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 }
809 }
810
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700811 //for now, only rssi, we can add more if needed
Madan Mohan Koyyalamudi3e9f2022012-12-04 16:34:19 -0800812 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700813 {
814 pBssDescr->bssDescription.rssi = rssi;
815 }
816
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 // Add this BSS description at same index
818 if (pprev == pMac->lim.gLimCachedScanHashTable[index])
819 {
820 pBssDescr->next = pMac->lim.gLimCachedScanHashTable[index];
821 pMac->lim.gLimCachedScanHashTable[index] = pBssDescr;
822 }
823 else
824 {
825 pBssDescr->next = pprev->next;
826 pprev->next = pBssDescr;
827 }
828 pMac->lim.gLimMlmScanResultLength +=
829 pBssDescr->bssDescription.length + sizeof(tANI_U16);
830
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700831 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 pBssDescr->bssDescription.length,
833 pMac->lim.gLimMlmScanResultLength);
834 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
835
836 // Send new BSS found indication to HDD if CFG option is set
837 if (!found) limSendSmeNeighborBssInd(pMac, pBssDescr);
838
839 //
840 // TODO: IF applicable, do we need to send:
841 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
842 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
843 //
844 return eHAL_STATUS_SUCCESS;
845}
846
847
848
849/**
850 * limDeleteHashEntry()
851 *
852 *FUNCTION:
853 * This function is called upon to delete
854 * a BSS description from scan result hash table.
855 *
856 *LOGIC:
857 *
858 *ASSUMPTIONS:
859 * NA
860 *
861 *NOTE:
862 * Yet to find the utility of the function
863 *
864 * @param pBssDescr - Pointer to BSS description to be
865 * deleted from the scan result hash table.
866 *
867 * @return None
868 */
869
870void limDeleteHashEntry(tLimScanResultNode *pBssDescr)
871{
872} /****** end limDeleteHashEntry() ******/
873
874
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700875#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
876/**
877 * limInitLfrHashTable()
878 *
879 *FUNCTION:
880 * This function is called upon receiving SME_START_REQ
881 * to initialize global cached Lfr scan hash table
882 *
883 *LOGIC:
884 *
885 *ASSUMPTIONS:
886 * NA
887 *
888 *NOTE:
889 * NA
890 *
891 * @param pMac - Pointer to Global MAC structure
892 * @return None
893 */
894
895void
896limInitLfrHashTable(tpAniSirGlobal pMac)
897{
898 tANI_U16 i;
899 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
900 pMac->lim.gLimCachedLfrScanHashTable[i] = NULL;
901} /****** end limInitLfrHashTable() ******/
902
903
904
905/**
906 * limLookupNaddLfrHashEntry()
907 *
908 *FUNCTION:
909 * This function is called upon receiving a Beacon or
910 * Probe Response frame during Lfr scan phase from FW to store
911 * received BSS description into Lfr scan result hash table.
912 *
913 *LOGIC:
914 *
915 *ASSUMPTIONS:
916 * NA
917 *
918 *NOTE:
919 * NA
920 *
921 * @param pMac - Pointer to Global MAC structure
922 * @param pBssDescr - Pointer to BSS description to be
923 * added to the Lfr scan result hash table.
924 * @param action - Indicates action to be performed
925 * when same BSS description is found. This is
926 * dependent on whether unique scan result to
927 * be stored or not.
928 *
929 * @return None
930 */
931
932eHalStatus
933limLookupNaddLfrHashEntry(tpAniSirGlobal pMac,
934 tLimScanResultNode *pBssDescr, tANI_U8 action,
935 tANI_U8 dontUpdateAll)
936{
937 tANI_U8 index, ssidLen = 0;
938 tLimScanResultNode *ptemp, *pprev;
939 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
940 int idx, len;
941 tANI_U8 *pbIe;
942 tANI_S8 rssi = 0;
943
944 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
945 ptemp = pMac->lim.gLimCachedLfrScanHashTable[index];
946
947 //ieFields start with TLV of SSID IE
948 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
949 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
950
951 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
952 {
953 //For infrastructure, check BSSID and SSID. For IBSS, check more
954 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530955 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
956 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700957 (tANI_U8 *) ptemp->bssDescription.bssId,
958 sizeof(tSirMacAddr))) && //matching BSSID
959 (pBssDescr->bssDescription.channelId ==
960 ptemp->bssDescription.channelId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530961 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700962 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
963 (tANI_U8) (ssidLen + 1)) &&
964 ((pSirCapTemp->ess) || //we are done for infrastructure
965 //For IBSS, nwType and channelId
966 (((pBssDescr->bssDescription.nwType ==
967 ptemp->bssDescription.nwType) &&
968 (pBssDescr->bssDescription.channelId ==
969 ptemp->bssDescription.channelId))))
970 )
971 {
972 // Found the same BSS description
973 if (action == LIM_HASH_UPDATE)
974 {
975 if(dontUpdateAll)
976 {
977 rssi = ptemp->bssDescription.rssi;
978 }
979
980 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
981 {
982 //We get a different, save the old frame WSC IE if it is there
983 idx = 0;
984 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
985 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
986 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
987 //Save WPS IE if it exists
988 pBssDescr->bssDescription.WscIeLen = 0;
989 while(idx < len)
990 {
991 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
992 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) &&
993 (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
994 {
995 //Found it
996 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
997 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530998 vos_mem_copy( pBssDescr->bssDescription.WscIeProbeRsp,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700999 pbIe, pbIe[1] + 2);
1000 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
1001 }
1002 break;
1003 }
1004 idx += pbIe[1] + 2;
1005 pbIe += pbIe[1] + 2;
1006 }
1007 }
1008
1009
1010 if(NULL != pMac->lim.gpLimMlmScanReq)
1011 {
1012 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
1013 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
1014 &pBssDescr->bssDescription.ieFields + 1))))
1015 return eHAL_STATUS_FAILURE;
1016 }
1017
1018 // Delete this entry
1019 if (ptemp == pMac->lim.gLimCachedLfrScanHashTable[index])
1020 pprev = pMac->lim.gLimCachedLfrScanHashTable[index] = ptemp->next;
1021 else
1022 pprev->next = ptemp->next;
1023
1024 pMac->lim.gLimMlmLfrScanResultLength -=
1025 ptemp->bssDescription.length + sizeof(tANI_U16);
1026
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301027 vos_mem_free(ptemp);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001028 }
1029 break;
1030 }
1031 }
1032
1033 //for now, only rssi, we can add more if needed
1034 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
1035 {
1036 pBssDescr->bssDescription.rssi = rssi;
1037 }
1038
1039 // Add this BSS description at same index
1040 if (pprev == pMac->lim.gLimCachedLfrScanHashTable[index])
1041 {
1042 pBssDescr->next = pMac->lim.gLimCachedLfrScanHashTable[index];
1043 pMac->lim.gLimCachedLfrScanHashTable[index] = pBssDescr;
1044 }
1045 else
1046 {
1047 pBssDescr->next = pprev->next;
1048 pprev->next = pBssDescr;
1049 }
1050 pMac->lim.gLimMlmLfrScanResultLength +=
1051 pBssDescr->bssDescription.length + sizeof(tANI_U16);
1052
1053 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id\n"),
1054 pBssDescr->bssDescription.length,
1055 pMac->lim.gLimMlmLfrScanResultLength);
1056 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
1057
1058 //
1059 // TODO: IF applicable, do we need to send:
1060 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
1061 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
1062 //
1063 return eHAL_STATUS_SUCCESS;
1064}
1065
1066
1067
1068/**
1069 * limDeleteLfrHashEntry()
1070 *
1071 *FUNCTION:
1072 * This function is called upon to delete
1073 * a BSS description from LFR scan result hash table.
1074 *
1075 *LOGIC:
1076 *
1077 *ASSUMPTIONS:
1078 * NA
1079 *
1080 *NOTE:
1081 * Yet to find the utility of the function
1082 *
1083 * @param pBssDescr - Pointer to BSS description to be
1084 * deleted from the LFR scan result hash table.
1085 *
1086 * @return None
1087 */
1088
1089void limDeleteLfrHashEntry(tLimScanResultNode *pBssDescr)
1090{
1091} /****** end limDeleteLfrHashEntry() ******/
1092
1093#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001094
1095/**
1096 * limCopyScanResult()
1097 *
1098 *FUNCTION:
1099 * This function is called by limProcessSmeMessages() while
1100 * sending SME_SCAN_RSP with scan result to HDD.
1101 *
1102 *LOGIC:
1103 * This function traverses the scan list stored in scan hash table
1104 *
1105 *ASSUMPTIONS:
1106 * NA
1107 *
1108 *NOTE:
1109 * NA
1110 *
1111 * @param pMac - Pointer to Global MAC structure
1112 * @param pDest - Destination pointer
1113 *
1114 * @return None
1115 */
1116
1117void
1118limCopyScanResult(tpAniSirGlobal pMac, tANI_U8 *pDest)
1119{
1120 tLimScanResultNode *ptemp;
1121 tANI_U16 i;
1122 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1123 {
1124 if ((ptemp = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1125 {
1126 while(ptemp)
1127 {
1128 /// Copy entire BSS description including length
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301129 vos_mem_copy( pDest,
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 (tANI_U8 *) &ptemp->bssDescription,
1131 ptemp->bssDescription.length + 2);
1132 pDest += ptemp->bssDescription.length + 2;
1133 ptemp = ptemp->next;
1134 }
1135 }
1136 }
1137} /****** end limCopyScanResult() ******/
1138
1139
1140
1141/**
1142 * limDeleteCachedScanResults()
1143 *
1144 *FUNCTION:
1145 * This function is called by limProcessSmeMessages() upon receiving
1146 * SME_SCAN_REQ with fresh scan result flag set.
1147 *
1148 *LOGIC:
1149 * This function traverses the scan list stored in scan hash table
1150 * and deletes the entries if any
1151 *
1152 *ASSUMPTIONS:
1153 * NA
1154 *
1155 *NOTE:
1156 * NA
1157 *
1158 * @param pMac - Pointer to Global MAC structure
1159 * @return None
1160 */
1161
1162void
1163limDeleteCachedScanResults(tpAniSirGlobal pMac)
1164{
1165 tLimScanResultNode *pNode, *pNextNode;
1166 tANI_U16 i;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301167
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1169 {
1170 if ((pNode = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1171 {
1172 while (pNode)
1173 {
1174 pNextNode = pNode->next;
1175
1176 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301177 vos_mem_free(pNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001178
1179 pNode = pNextNode;
1180 }
1181 }
1182 }
1183
1184 pMac->lim.gLimSmeScanResultLength = 0;
1185} /****** end limDeleteCachedScanResults() ******/
1186
1187
1188
1189/**
1190 * limReInitScanResults()
1191 *
1192 *FUNCTION:
1193 * This function is called delete exisiting scan results
1194 * and initialize the scan hash table
1195 *
1196 *LOGIC:
1197 *
1198 *ASSUMPTIONS:
1199 * NA
1200 *
1201 *NOTE:
1202 * NA
1203 *
1204 * @param pMac - Pointer to Global MAC structure
1205 * @return None
1206 */
1207
1208void
1209limReInitScanResults(tpAniSirGlobal pMac)
1210{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301211 limLog(pMac, LOG1, FL("Re initialize scan hash table."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 limDeleteCachedScanResults(pMac);
1213 limInitHashTable(pMac);
1214
1215 // !!LAC - need to clear out the global scan result length
1216 // since the list was just purged from the hash table.
1217 pMac->lim.gLimMlmScanResultLength = 0;
1218
1219} /****** end limReInitScanResults() ******/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001220#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1221/**
1222 * limDeleteCachedLfrScanResults()
1223 *
1224 *FUNCTION:
1225 * This function is called by limProcessSmeMessages() upon receiving
1226 * SME_SCAN_REQ with flush scan result flag set for LFR.
1227 *
1228 *LOGIC:
1229 * This function traverses the scan list stored in lfr scan hash
1230 * table and deletes the entries if any
1231 *
1232 *ASSUMPTIONS:
1233 * NA
1234 *
1235 *NOTE:
1236 * NA
1237 *
1238 * @param pMac - Pointer to Global MAC structure
1239 * @return None
1240 */
1241
1242void
1243limDeleteCachedLfrScanResults(tpAniSirGlobal pMac)
1244{
1245 tLimScanResultNode *pNode, *pNextNode;
1246 tANI_U16 i;
1247 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1248 {
1249 if ((pNode = pMac->lim.gLimCachedLfrScanHashTable[i]) != NULL)
1250 {
1251 while (pNode)
1252 {
1253 pNextNode = pNode->next;
1254
1255 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301256 vos_mem_free(pNode);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001257
1258 pNode = pNextNode;
1259 }
1260 }
1261 }
1262
1263 pMac->lim.gLimSmeLfrScanResultLength = 0;
1264} /****** end limDeleteCachedLfrScanResults() ******/
1265
1266
1267
1268/**
1269 * limReInitLfrScanResults()
1270 *
1271 *FUNCTION:
1272 * This function is called delete exisiting scan results
1273 * and initialize the lfr scan hash table
1274 *
1275 *LOGIC:
1276 *
1277 *ASSUMPTIONS:
1278 * NA
1279 *
1280 *NOTE:
1281 * NA
1282 *
1283 * @param pMac - Pointer to Global MAC structure
1284 * @return None
1285 */
1286
1287void
1288limReInitLfrScanResults(tpAniSirGlobal pMac)
1289{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301290 limLog(pMac, LOG1, FL("Re initialize lfr scan hash table."));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001291 limDeleteCachedLfrScanResults(pMac);
1292 limInitLfrHashTable(pMac);
1293
1294 // !!LAC - need to clear out the global scan result length
1295 // since the list was just purged from the hash table.
1296 pMac->lim.gLimMlmLfrScanResultLength = 0;
1297
1298} /****** end limReInitLfrScanResults() ******/
1299#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD