blob: c735bc8f944dc1d8c39d32b21a54d195f369849a [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{
74 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) && (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE))
75 {
76 /**
77 * Beacon/Probe Response is received during active scanning.
78 * Deactivate MIN channel timer if running.
79 */
80
81 limDeactivateAndChangeTimer(pMac,eLIM_MIN_CHANNEL_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -070082 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_MAX_CHANNEL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -070083 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
84 == TX_TIMER_ERROR)
85 {
86 /// Could not activate max channel timer.
87 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -070088 limLog(pMac,LOGP, FL("could not activate max channel timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070089
90 limCompleteMlmScan(pMac, eSIR_SME_RESOURCES_UNAVAILABLE);
91 return TX_TIMER_ERROR;
92 }
93 }
94 return eSIR_SUCCESS;
95} /*** end limDeactivateMinChannelTimerDuringScan() ***/
96
97
98
99/**
100 * limCollectBssDescription()
101 *
102 *FUNCTION:
103 * This function is called during scan upon receiving
104 * Beacon/Probe Response frame to check if the received
105 * frame matches scan criteria, collect BSS description
106 * and add it to cached scan results.
107 *
108 *LOGIC:
109 *
110 *ASSUMPTIONS:
111 * NA
112 *
113 *NOTE:
114 * NA
115 *
116 * @param pMac - Pointer to Global MAC structure
117 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
118 * @param pRxPacketInfo - Pointer to Received frame's BD
119 * ---------if defined WLAN_FEATURE_VOWIFI------
120 * @param fScanning - flag to indicate if it is during scan.
121 * ---------------------------------------------
122 *
123 * @return None
124 */
125#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530126eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700127limCollectBssDescription(tpAniSirGlobal pMac,
128 tSirBssDescription *pBssDescr,
129 tpSirProbeRespBeacon pBPR,
130 tANI_U8 *pRxPacketInfo,
131 tANI_U8 fScanning)
132#else
Kiet Lam623403f2013-10-21 20:29:40 +0530133eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700134limCollectBssDescription(tpAniSirGlobal pMac,
135 tSirBssDescription *pBssDescr,
136 tpSirProbeRespBeacon pBPR,
137 tANI_U8 *pRxPacketInfo)
138#endif
139{
140 tANI_U8 *pBody;
141 tANI_U32 ieLen = 0;
142 tpSirMacMgmtHdr pHdr;
143 tANI_U8 channelNum;
144 tANI_U8 rxChannel;
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700145 tANI_U8 rfBand = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146
147 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800148 VOS_ASSERT(WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) >= SIR_MAC_B_PR_SSID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) - SIR_MAC_B_PR_SSID_OFFSET;
150 rxChannel = WDA_GET_RX_CH(pRxPacketInfo);
151 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700152 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700153
Kiet Lam623403f2013-10-21 20:29:40 +0530154 /**
155 * Drop all the beacons and probe response without P2P IE during P2P search
156 */
157 if (NULL != pMac->lim.gpLimMlmScanReq && pMac->lim.gpLimMlmScanReq->p2pSearch)
158 {
159 if (NULL == limGetP2pIEPtr(pMac, (pBody + SIR_MAC_B_PR_SSID_OFFSET), ieLen))
160 {
161 limLog( pMac, LOG3, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHdr->bssId));
162 return eHAL_STATUS_FAILURE;
163 }
164 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700165
166 /**
167 * Length of BSS desription is without length of
168 * length itself and length of pointer
169 * that holds the next BSS description
170 */
171 pBssDescr->length = (tANI_U16)(
172 sizeof(tSirBssDescription) - sizeof(tANI_U16) -
173 sizeof(tANI_U32) + ieLen);
174
175 // Copy BSS Id
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530176 vos_mem_copy((tANI_U8 *) &pBssDescr->bssId,
177 (tANI_U8 *) pHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 sizeof(tSirMacAddr));
179
180 // Copy Timestamp, Beacon Interval and Capability Info
181 pBssDescr->scanSysTimeMsec = vos_timer_get_system_time();
182
183 pBssDescr->timeStamp[0] = pBPR->timeStamp[0];
184 pBssDescr->timeStamp[1] = pBPR->timeStamp[1];
185 pBssDescr->beaconInterval = pBPR->beaconInterval;
186 pBssDescr->capabilityInfo = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
187
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +0530188 if(!pBssDescr->beaconInterval )
189 {
190 limLog(pMac, LOGW,
191 FL("Beacon Interval is ZERO, making it to default 100 "
192 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->bssId));
193 pBssDescr->beaconInterval= 100;
194 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 /*
196 * There is a narrow window after Channel Switch msg is sent to HAL and before the AGC is shut
197 * down and beacons/Probe Rsps can trickle in and we may report the incorrect channel in 5Ghz
198 * band, so not relying on the 'last Scanned Channel' stored in LIM.
199 * Instead use the value returned by RXP in BD. This the the same value which HAL programs into
200 * RXP before every channel switch.
201 * Right now there is a problem in 5Ghz, where we are receiving beacons from a channel different from
202 * the currently scanned channel. so incorrect channel is reported to CSR and association does not happen.
203 * So for now we keep on looking for the channel info in the beacon (DSParamSet IE OR HT Info IE), and only if it
204 * is not present in the beacon, we go for the channel info present in RXP.
205 * 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.
206 * So The problem of incorrect channel reporting in 5Ghz will still remain for 11a devices.
207 */
208 pBssDescr->channelId = limGetChannelFromBeacon(pMac, pBPR);
209
210 if (pBssDescr->channelId == 0)
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700211 {
212 /* If the channel Id is not retrieved from Beacon, extract the channel from BD */
213 /* Unmapped the channel.This We have to do since we have done mapping in the hal to
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 overcome the limitation of RXBD of not able to accomodate the bigger channel number.*/
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700215 if ((!rfBand) || IS_5G_BAND(rfBand))
216 {
217 rxChannel = limUnmapChannel(rxChannel);
218 }
219 if (!rxChannel)
220 {
221 rxChannel = pMac->lim.gLimCurrentScanChannelId;
222 }
223 pBssDescr->channelId = rxChannel;
224 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530226 pBssDescr->channelIdSelf = pBssDescr->channelId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700227 //set the network type in bss description
228 channelNum = pBssDescr->channelId;
229 pBssDescr->nwType = limGetNwType(pMac, channelNum, SIR_MAC_MGMT_FRAME, pBPR);
230
231 pBssDescr->aniIndicator = pBPR->propIEinfo.aniIndicator;
232
233 // Copy RSSI & SINR from BD
234
235 PELOG4(limLog(pMac, LOG4, "***********BSS Description for BSSID:*********** ");
236 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pBssDescr->bssId, 6 );
237 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG4, (tANI_U8*)pRxPacketInfo, 36 );)
238
239 pBssDescr->rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo);
240
241 //SINR no longer reported by HW
242 pBssDescr->sinr = 0;
243
244 pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
245
246#if defined WLAN_FEATURE_VOWIFI
247 if( fScanning )
248 {
249 rrmGetStartTSF( pMac, pBssDescr->startTSF );
250 pBssDescr->parentTSF = WDA_GET_RX_TIMESTAMP(pRxPacketInfo);
251 }
252#endif
253
254#ifdef WLAN_FEATURE_VOWIFI_11R
255 // MobilityDomain
256 pBssDescr->mdie[0] = 0;
257 pBssDescr->mdie[1] = 0;
258 pBssDescr->mdie[2] = 0;
259 pBssDescr->mdiePresent = FALSE;
260 // If mdie is present in the probe resp we
261 // fill it in the bss description
262 if( pBPR->mdiePresent)
263 {
264 pBssDescr->mdiePresent = TRUE;
265 pBssDescr->mdie[0] = pBPR->mdie[0];
266 pBssDescr->mdie[1] = pBPR->mdie[1];
267 pBssDescr->mdie[2] = pBPR->mdie[2];
268 }
269#endif
270
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800271#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 pBssDescr->QBSSLoad_present = FALSE;
273 pBssDescr->QBSSLoad_avail = 0;
274 if( pBPR->QBSSLoad.present)
275 {
276 pBssDescr->QBSSLoad_present = TRUE;
277 pBssDescr->QBSSLoad_avail = pBPR->QBSSLoad.avail;
278 }
279#endif
280 // Copy IE fields
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530281 vos_mem_copy((tANI_U8 *) &pBssDescr->ieFields,
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 pBody + SIR_MAC_B_PR_SSID_OFFSET,
283 ieLen);
284
285 //sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGW, (tANI_U8 *) pBssDescr, pBssDescr->length + 2 );
286 limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700287 FL("Collected BSS Description for Channel(%1d), length(%u), aniIndicator(%d), IE Fields(%u)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 pBssDescr->channelId,
289 pBssDescr->length,
290 pBssDescr->aniIndicator,
291 ieLen );
292
Kiet Lam623403f2013-10-21 20:29:40 +0530293 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700294} /*** end limCollectBssDescription() ***/
295
296/**
297 * limIsScanRequestedSSID()
298 *
299 *FUNCTION:
300 * This function is called during scan upon receiving
301 * Beacon/Probe Response frame to check if the received
302 * SSID is present in the list of requested SSIDs in scan
303 *
304 *LOGIC:
305 *
306 *ASSUMPTIONS:
307 * NA
308 *
309 *NOTE:
310 * NA
311 *
312 * @param pMac - Pointer to Global MAC structure
313 * @param ssId - SSID Received in beacons/Probe responses that is compared against the
314 requeusted SSID in scan list
315 * ---------------------------------------------
316 *
317 * @return boolean - TRUE if SSID is present in requested list, FALSE otherwise
318 */
319
320tANI_BOOLEAN limIsScanRequestedSSID(tpAniSirGlobal pMac, tSirMacSSid *ssId)
321{
322 tANI_U8 i = 0;
323
324 for (i = 0; i < pMac->lim.gpLimMlmScanReq->numSsid; i++)
325 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530326 if ( eANI_BOOLEAN_TRUE == vos_mem_compare((tANI_U8 *) ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 (tANI_U8 *) &pMac->lim.gpLimMlmScanReq->ssId[i],
328 (tANI_U8) (pMac->lim.gpLimMlmScanReq->ssId[i].length + 1)))
329 {
330 return eANI_BOOLEAN_TRUE;
331 }
332 }
333 return eANI_BOOLEAN_FALSE;
334}
335
336/**
337 * limCheckAndAddBssDescription()
338 *
339 *FUNCTION:
340 * This function is called during scan upon receiving
341 * Beacon/Probe Response frame to check if the received
342 * frame matches scan criteria, collect BSS description
343 * and add it to cached scan results.
344 *
345 *LOGIC:
346 *
347 *ASSUMPTIONS:
348 * NA
349 *
350 *NOTE:
351 * NA
352 *
353 * @param pMac - Pointer to Global MAC structure
354 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
355 * @param pRxPacketInfo - Pointer to Received frame's BD
356 * @param fScanning - boolean to indicate whether the BSS is from current scan or just happen to receive a beacon
357 *
358 * @return None
359 */
360
361void
362limCheckAndAddBssDescription(tpAniSirGlobal pMac,
363 tpSirProbeRespBeacon pBPR,
364 tANI_U8 *pRxPacketInfo,
365 tANI_BOOLEAN fScanning,
366 tANI_U8 fProbeRsp)
367{
368 tLimScanResultNode *pBssDescr;
369 tANI_U32 frameLen, ieLen = 0;
370 tANI_U8 rxChannelInBeacon = 0;
371 eHalStatus status;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700372 tANI_U8 dontUpdateAll = 0;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700373 tANI_U8 rfBand = 0;
374 tANI_U8 rxChannelInBD = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700375
Jeff Johnson295189b2012-06-20 16:38:30 -0700376 tSirMacAddr bssid = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
Agrawal Ashish9948e082014-07-17 13:48:37 +0530377 tSirMacAddr bssid_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 tANI_BOOLEAN fFound = FALSE;
379 tpSirMacDataHdr3a pHdr;
380
381 pHdr = WDA_GET_RX_MPDUHEADER3A((tANI_U8 *)pRxPacketInfo);
382
Agrawal Ashish9948e082014-07-17 13:48:37 +0530383 // Check For Null BSSID; Skip in case of P2P.
384 if (vos_mem_compare(bssid_zero, &pHdr->addr3, 6))
385 {
386 return ;
387 }
388
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 //Checking if scanning for a particular BSSID
390 if ((fScanning) && (pMac->lim.gpLimMlmScanReq))
391 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530392 fFound = vos_mem_compare(pHdr->addr3, &pMac->lim.gpLimMlmScanReq->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 if (!fFound)
394 {
395 if ((pMac->lim.gpLimMlmScanReq->p2pSearch) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530396 (vos_mem_compare(pBPR->P2PProbeRes.P2PDeviceInfo.P2PDeviceAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 &pMac->lim.gpLimMlmScanReq->bssId, 6)))
398 {
399 fFound = eANI_BOOLEAN_TRUE;
400 }
401 }
402 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700403
404 /**
405 * Compare SSID with the one sent in
406 * Probe Request frame, if any.
407 * If they don't match, ignore the
408 * Beacon frame.
409 * pMac->lim.gLimMlmScanReq->ssId.length == 0
410 * indicates Broadcast SSID.
411 * When gLimReturnAfterFirstMatch is set, it means the scan has to match
412 * a SSID (if it is also set). Ignore the other BSS in that case.
413 */
414
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700415#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
416 if (!(WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo)))
417 {
418#endif
419 if ((pMac->lim.gpLimMlmScanReq) &&
420 (((fScanning) &&
421 ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) &&
422 (pMac->lim.gpLimMlmScanReq->numSsid) &&
423 !limIsScanRequestedSSID(pMac, &pBPR->ssId)) ||
424 (!fFound && (pMac->lim.gpLimMlmScanReq &&
425 pMac->lim.gpLimMlmScanReq->bssId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530426 !vos_mem_compare(bssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700427 &pMac->lim.gpLimMlmScanReq->bssId, 6))))
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 {
429 /**
430 * Received SSID does not match with
431 * the one we're scanning for.
432 * Ignore received Beacon frame
433 */
434
435 return;
436 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700437#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
438 }
439#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700440
441 /* There is no point in caching & reporting the scan results for APs
442 * which are in the process of switching the channel. So, we are not
443 * caching the scan results for APs which are adverzing the channel-switch
444 * element in their beacons and probe responses.
445 */
446 if(pBPR->channelSwitchPresent)
447 {
448 return;
449 }
450
451 /* If beacon/probe resp DS param channel does not match with
452 * RX BD channel then don't save the results. It might be a beacon
453 * from another channel heard as noise on the current scanning channel
454 */
455
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700456 if ((pBPR->dsParamsPresent) || (pBPR->HTInfo.present))
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 {
458 /* This means that we are in 2.4GHz mode or 5GHz 11n mode */
459 rxChannelInBeacon = limGetChannelFromBeacon(pMac, pBPR);
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700460 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
461 rxChannelInBD = WDA_GET_RX_CH(pRxPacketInfo);
462
463 if ((!rfBand) || IS_5G_BAND(rfBand))
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 {
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700465 rxChannelInBD = limUnmapChannel(rxChannelInBD);
466 }
467
468 if(rxChannelInBD != rxChannelInBeacon)
469 {
470 /* BCAST Frame, if CH do not match, Drop */
471 if(WDA_IS_RX_BCAST(pRxPacketInfo))
472 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700473 limLog(pMac, LOG3, FL("Beacon/Probe Rsp dropped. Channel in BD %d. "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700474 "Channel in beacon" " %d"),
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700475 WDA_GET_RX_CH(pRxPacketInfo),limGetChannelFromBeacon(pMac, pBPR));
476 return;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700477 }
478 /* Unit cast frame, Probe RSP, do not drop */
479 else
480 {
481 dontUpdateAll = 1;
482 limLog(pMac, LOG3, FL("SSID %s, CH in ProbeRsp %d, CH in BD %d, miss-match, Do Not Drop"),
483 pBPR->ssId.ssId,
484 rxChannelInBeacon,
485 WDA_GET_RX_CH(pRxPacketInfo));
486 WDA_GET_RX_CH(pRxPacketInfo) = rxChannelInBeacon;
487 }
488 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 }
490
491 /**
492 * Allocate buffer to hold BSS description from
493 * received Beacon frame.
494 * Include size of fixed fields and IEs length
495 */
496
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800497 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
498 if (ieLen <= SIR_MAC_B_PR_SSID_OFFSET)
499 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700500 limLog(pMac, LOGP,
501 FL("RX packet has invalid length %d"), ieLen);
502 return;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800503 }
504
505 ieLen -= SIR_MAC_B_PR_SSID_OFFSET;
506
507 frameLen = sizeof(tLimScanResultNode) + ieLen - sizeof(tANI_U32); //Sizeof(tANI_U32) is for ieFields[1]
Jeff Johnson295189b2012-06-20 16:38:30 -0700508
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530509 pBssDescr = vos_mem_malloc(frameLen);
510 if ( NULL == pBssDescr )
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 {
512 // Log error
513 limLog(pMac, LOGP,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530514 FL("call for AllocateMemory failed for storing BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700515
516 return;
517 }
518
519 // In scan state, store scan result.
520#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530521 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 pBPR, pRxPacketInfo, fScanning);
Kiet Lam623403f2013-10-21 20:29:40 +0530523 if (eHAL_STATUS_SUCCESS != status)
524 {
525 goto last;
526 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700527#else
Kiet Lam623403f2013-10-21 20:29:40 +0530528 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 pBPR, pRxPacketInfo);
Kiet Lam623403f2013-10-21 20:29:40 +0530530 if (eHAL_STATUS_SUCCESS != status)
531 {
532 goto last;
533 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700534#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 pBssDescr->bssDescription.fProbeRsp = fProbeRsp;
536
537 pBssDescr->next = NULL;
538
539 /**
540 * Depending on whether to store unique or all
541 * scan results, pass hash update/add parameter
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700542 * For LFR candidates just add them on it's own cache
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 */
544
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700545#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
546 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
547 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800548 limLog(pMac, LOG2, FL(" pHdr->addr1:"MAC_ADDRESS_STR),
549 MAC_ADDR_ARRAY(pHdr->addr1));
550 limLog(pMac, LOG2, FL(" pHdr->addr2:"MAC_ADDRESS_STR),
551 MAC_ADDR_ARRAY(pHdr->addr2));
552 limLog(pMac, LOG2, FL(" pHdr->addr3:"MAC_ADDRESS_STR),
553 MAC_ADDR_ARRAY(pHdr->addr3));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700554 limLog( pMac, LOG2, FL("Save this entry in LFR cache"));
555 status = limLookupNaddLfrHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
556 }
557 else
558#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 //If it is not scanning, only save unique results
560 if (pMac->lim.gLimReturnUniqueResults || (!fScanning))
561 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700562 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_UPDATE, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 }
564 else
565 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700566 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 }
568
569 if(fScanning)
570 {
571 if ((pBssDescr->bssDescription.channelId <= 14) &&
572 (pMac->lim.gLimReturnAfterFirstMatch & 0x40) &&
573 pBPR->countryInfoPresent)
574 pMac->lim.gLim24Band11dScanDone = 1;
575
576 if ((pBssDescr->bssDescription.channelId > 14) &&
577 (pMac->lim.gLimReturnAfterFirstMatch & 0x80) &&
578 pBPR->countryInfoPresent)
579 pMac->lim.gLim50Band11dScanDone = 1;
580
581 if ( ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) ||
582 ( pMac->lim.gLim24Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x40 ) ) ||
Gopichand Nakkala48b4d7e2013-03-06 23:34:16 +0530583 ( pMac->lim.gLim50Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x80 ) ) ||
584 fFound )
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 {
586 /**
587 * Stop scanning and return the BSS description(s)
588 * collected so far.
589 */
590 limLog(pMac,
591 LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700592 FL("Completed scan: 24Band11dScan = %d, 50Band11dScan = %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 pMac->lim.gLim24Band11dScanDone,
594 pMac->lim.gLim50Band11dScanDone);
595
596 //Need to disable the timers. If they fire, they will send END_SCAN
597 //while we already send FINISH_SCAN here. This may mess up the gLimHalScanState
598 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
599 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
600 //Set the resume channel to Any valid channel (invalid).
601 //This will instruct HAL to set it to any previous valid channel.
602 peSetResumeChannel(pMac, 0, 0);
603 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
604 //limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
605 }
606 }//(eANI_BOOLEAN_TRUE == fScanning)
607
Kiet Lam623403f2013-10-21 20:29:40 +0530608last:
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 if( eHAL_STATUS_SUCCESS != status )
610 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530611 vos_mem_free( pBssDescr );
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 }
Kiet Lam623403f2013-10-21 20:29:40 +0530613 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700614} /****** end limCheckAndAddBssDescription() ******/
615
616
617
618/**
619 * limScanHashFunction()
620 *
621 *FUNCTION:
622 * This function is called during scan hash entry operations
623 *
624 *LOGIC:
625 *
626 *ASSUMPTIONS:
627 * NA
628 *
629 *NOTE:
630 * NA
631 *
632 * @param bssId - Received BSSid
633 *
634 * @return Hash index
635 */
636
637tANI_U8
638limScanHashFunction(tSirMacAddr bssId)
639{
640 tANI_U16 i, hash = 0;
641
642 for (i = 0; i < sizeof(tSirMacAddr); i++)
643 hash += bssId[i];
644
645 return hash % LIM_MAX_NUM_OF_SCAN_RESULTS;
646} /****** end limScanHashFunction() ******/
647
648
649
650/**
651 * limInitHashTable()
652 *
653 *FUNCTION:
654 * This function is called upon receiving SME_START_REQ
655 * to initialize global cached scan hash table
656 *
657 *LOGIC:
658 *
659 *ASSUMPTIONS:
660 * NA
661 *
662 *NOTE:
663 * NA
664 *
665 * @param pMac - Pointer to Global MAC structure
666 * @return None
667 */
668
669void
670limInitHashTable(tpAniSirGlobal pMac)
671{
672 tANI_U16 i;
673 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
674 pMac->lim.gLimCachedScanHashTable[i] = NULL;
675} /****** end limInitHashTable() ******/
676
677
678
679/**
680 * limLookupNaddHashEntry()
681 *
682 *FUNCTION:
683 * This function is called upon receiving a Beacon or
684 * Probe Response frame during scan phase to store
685 * received BSS description into scan result hash table.
686 *
687 *LOGIC:
688 *
689 *ASSUMPTIONS:
690 * NA
691 *
692 *NOTE:
693 * NA
694 *
695 * @param pMac - Pointer to Global MAC structure
696 * @param pBssDescr - Pointer to BSS description to be
697 * added to the scan result hash table.
698 * @param action - Indicates action to be performed
699 * when same BSS description is found. This is
700 * dependent on whether unique scan result to
701 * be stored or not.
702 *
703 * @return None
704 */
705
706eHalStatus
707limLookupNaddHashEntry(tpAniSirGlobal pMac,
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700708 tLimScanResultNode *pBssDescr, tANI_U8 action,
709 tANI_U8 dontUpdateAll)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710{
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700711 tANI_U8 index, ssidLen = 0;
712 tANI_U8 found = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 tLimScanResultNode *ptemp, *pprev;
714 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
715 int idx, len;
716 tANI_U8 *pbIe;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700717 tANI_S8 rssi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700718
719 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
720 ptemp = pMac->lim.gLimCachedScanHashTable[index];
721
722 //ieFields start with TLV of SSID IE
723 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
724 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
725
726 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
727 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700728 //For infrastructure, check BSSID and SSID. For IBSS, check more
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530730 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
731 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 (tANI_U8 *) ptemp->bssDescription.bssId,
733 sizeof(tSirMacAddr))) && //matching BSSID
Abhishek Singhe3fa11f2014-05-13 11:11:10 +0530734 // matching band to update new channel info
735 (vos_chan_to_band(pBssDescr->bssDescription.channelId) ==
736 vos_chan_to_band(ptemp->bssDescription.channelId)) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530737 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
739 (tANI_U8) (ssidLen + 1)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700740 ((pSirCapTemp->ess) || //we are done for infrastructure
741 //For IBSS, nwType and channelId
742 (((pBssDescr->bssDescription.nwType ==
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 ptemp->bssDescription.nwType) &&
744 (pBssDescr->bssDescription.channelId ==
745 ptemp->bssDescription.channelId))))
746 )
747 {
748 // Found the same BSS description
749 if (action == LIM_HASH_UPDATE)
750 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700751 if(dontUpdateAll)
752 {
753 rssi = ptemp->bssDescription.rssi;
754 }
755
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
757 {
758 //We get a different, save the old frame WSC IE if it is there
759 idx = 0;
760 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
761 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
762 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
763 //Save WPS IE if it exists
764 pBssDescr->bssDescription.WscIeLen = 0;
765 while(idx < len)
766 {
767 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
768 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
769 {
770 //Found it
771 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
772 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530773 vos_mem_copy(pBssDescr->bssDescription.WscIeProbeRsp,
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 pbIe, pbIe[1] + 2);
775 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
776 }
777 break;
778 }
779 idx += pbIe[1] + 2;
780 pbIe += pbIe[1] + 2;
781 }
782 }
783
784
785 if(NULL != pMac->lim.gpLimMlmScanReq)
786 {
787 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
788 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
789 &pBssDescr->bssDescription.ieFields + 1))))
790 return eHAL_STATUS_FAILURE;
791 }
792
793 // Delete this entry
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700794 if (ptemp == pMac->lim.gLimCachedScanHashTable[index])
795 pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 else
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700797 pprev->next = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700798
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700799 pMac->lim.gLimMlmScanResultLength -=
800 ptemp->bssDescription.length + sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -0700801
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530802 vos_mem_free(ptemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 }
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700804 found = true;
805 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 }
807 }
808
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700809 //for now, only rssi, we can add more if needed
Madan Mohan Koyyalamudi3e9f2022012-12-04 16:34:19 -0800810 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700811 {
812 pBssDescr->bssDescription.rssi = rssi;
813 }
814
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 // Add this BSS description at same index
816 if (pprev == pMac->lim.gLimCachedScanHashTable[index])
817 {
818 pBssDescr->next = pMac->lim.gLimCachedScanHashTable[index];
819 pMac->lim.gLimCachedScanHashTable[index] = pBssDescr;
820 }
821 else
822 {
823 pBssDescr->next = pprev->next;
824 pprev->next = pBssDescr;
825 }
826 pMac->lim.gLimMlmScanResultLength +=
827 pBssDescr->bssDescription.length + sizeof(tANI_U16);
828
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700829 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 pBssDescr->bssDescription.length,
831 pMac->lim.gLimMlmScanResultLength);
832 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
833
834 // Send new BSS found indication to HDD if CFG option is set
835 if (!found) limSendSmeNeighborBssInd(pMac, pBssDescr);
836
837 //
838 // TODO: IF applicable, do we need to send:
839 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
840 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
841 //
842 return eHAL_STATUS_SUCCESS;
843}
844
845
846
847/**
848 * limDeleteHashEntry()
849 *
850 *FUNCTION:
851 * This function is called upon to delete
852 * a BSS description from scan result hash table.
853 *
854 *LOGIC:
855 *
856 *ASSUMPTIONS:
857 * NA
858 *
859 *NOTE:
860 * Yet to find the utility of the function
861 *
862 * @param pBssDescr - Pointer to BSS description to be
863 * deleted from the scan result hash table.
864 *
865 * @return None
866 */
867
868void limDeleteHashEntry(tLimScanResultNode *pBssDescr)
869{
870} /****** end limDeleteHashEntry() ******/
871
872
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700873#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
874/**
875 * limInitLfrHashTable()
876 *
877 *FUNCTION:
878 * This function is called upon receiving SME_START_REQ
879 * to initialize global cached Lfr scan hash table
880 *
881 *LOGIC:
882 *
883 *ASSUMPTIONS:
884 * NA
885 *
886 *NOTE:
887 * NA
888 *
889 * @param pMac - Pointer to Global MAC structure
890 * @return None
891 */
892
893void
894limInitLfrHashTable(tpAniSirGlobal pMac)
895{
896 tANI_U16 i;
897 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
898 pMac->lim.gLimCachedLfrScanHashTable[i] = NULL;
899} /****** end limInitLfrHashTable() ******/
900
901
902
903/**
904 * limLookupNaddLfrHashEntry()
905 *
906 *FUNCTION:
907 * This function is called upon receiving a Beacon or
908 * Probe Response frame during Lfr scan phase from FW to store
909 * received BSS description into Lfr scan result hash table.
910 *
911 *LOGIC:
912 *
913 *ASSUMPTIONS:
914 * NA
915 *
916 *NOTE:
917 * NA
918 *
919 * @param pMac - Pointer to Global MAC structure
920 * @param pBssDescr - Pointer to BSS description to be
921 * added to the Lfr scan result hash table.
922 * @param action - Indicates action to be performed
923 * when same BSS description is found. This is
924 * dependent on whether unique scan result to
925 * be stored or not.
926 *
927 * @return None
928 */
929
930eHalStatus
931limLookupNaddLfrHashEntry(tpAniSirGlobal pMac,
932 tLimScanResultNode *pBssDescr, tANI_U8 action,
933 tANI_U8 dontUpdateAll)
934{
935 tANI_U8 index, ssidLen = 0;
936 tLimScanResultNode *ptemp, *pprev;
937 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
938 int idx, len;
939 tANI_U8 *pbIe;
940 tANI_S8 rssi = 0;
941
942 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
943 ptemp = pMac->lim.gLimCachedLfrScanHashTable[index];
944
945 //ieFields start with TLV of SSID IE
946 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
947 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
948
949 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
950 {
951 //For infrastructure, check BSSID and SSID. For IBSS, check more
952 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530953 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
954 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700955 (tANI_U8 *) ptemp->bssDescription.bssId,
956 sizeof(tSirMacAddr))) && //matching BSSID
957 (pBssDescr->bssDescription.channelId ==
958 ptemp->bssDescription.channelId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530959 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700960 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
961 (tANI_U8) (ssidLen + 1)) &&
962 ((pSirCapTemp->ess) || //we are done for infrastructure
963 //For IBSS, nwType and channelId
964 (((pBssDescr->bssDescription.nwType ==
965 ptemp->bssDescription.nwType) &&
966 (pBssDescr->bssDescription.channelId ==
967 ptemp->bssDescription.channelId))))
968 )
969 {
970 // Found the same BSS description
971 if (action == LIM_HASH_UPDATE)
972 {
973 if(dontUpdateAll)
974 {
975 rssi = ptemp->bssDescription.rssi;
976 }
977
978 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
979 {
980 //We get a different, save the old frame WSC IE if it is there
981 idx = 0;
982 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
983 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
984 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
985 //Save WPS IE if it exists
986 pBssDescr->bssDescription.WscIeLen = 0;
987 while(idx < len)
988 {
989 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
990 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) &&
991 (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
992 {
993 //Found it
994 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
995 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530996 vos_mem_copy( pBssDescr->bssDescription.WscIeProbeRsp,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700997 pbIe, pbIe[1] + 2);
998 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
999 }
1000 break;
1001 }
1002 idx += pbIe[1] + 2;
1003 pbIe += pbIe[1] + 2;
1004 }
1005 }
1006
1007
1008 if(NULL != pMac->lim.gpLimMlmScanReq)
1009 {
1010 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
1011 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
1012 &pBssDescr->bssDescription.ieFields + 1))))
1013 return eHAL_STATUS_FAILURE;
1014 }
1015
1016 // Delete this entry
1017 if (ptemp == pMac->lim.gLimCachedLfrScanHashTable[index])
1018 pprev = pMac->lim.gLimCachedLfrScanHashTable[index] = ptemp->next;
1019 else
1020 pprev->next = ptemp->next;
1021
1022 pMac->lim.gLimMlmLfrScanResultLength -=
1023 ptemp->bssDescription.length + sizeof(tANI_U16);
1024
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301025 vos_mem_free(ptemp);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001026 }
1027 break;
1028 }
1029 }
1030
1031 //for now, only rssi, we can add more if needed
1032 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
1033 {
1034 pBssDescr->bssDescription.rssi = rssi;
1035 }
1036
1037 // Add this BSS description at same index
1038 if (pprev == pMac->lim.gLimCachedLfrScanHashTable[index])
1039 {
1040 pBssDescr->next = pMac->lim.gLimCachedLfrScanHashTable[index];
1041 pMac->lim.gLimCachedLfrScanHashTable[index] = pBssDescr;
1042 }
1043 else
1044 {
1045 pBssDescr->next = pprev->next;
1046 pprev->next = pBssDescr;
1047 }
1048 pMac->lim.gLimMlmLfrScanResultLength +=
1049 pBssDescr->bssDescription.length + sizeof(tANI_U16);
1050
1051 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id\n"),
1052 pBssDescr->bssDescription.length,
1053 pMac->lim.gLimMlmLfrScanResultLength);
1054 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
1055
1056 //
1057 // TODO: IF applicable, do we need to send:
1058 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
1059 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
1060 //
1061 return eHAL_STATUS_SUCCESS;
1062}
1063
1064
1065
1066/**
1067 * limDeleteLfrHashEntry()
1068 *
1069 *FUNCTION:
1070 * This function is called upon to delete
1071 * a BSS description from LFR scan result hash table.
1072 *
1073 *LOGIC:
1074 *
1075 *ASSUMPTIONS:
1076 * NA
1077 *
1078 *NOTE:
1079 * Yet to find the utility of the function
1080 *
1081 * @param pBssDescr - Pointer to BSS description to be
1082 * deleted from the LFR scan result hash table.
1083 *
1084 * @return None
1085 */
1086
1087void limDeleteLfrHashEntry(tLimScanResultNode *pBssDescr)
1088{
1089} /****** end limDeleteLfrHashEntry() ******/
1090
1091#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001092
1093/**
1094 * limCopyScanResult()
1095 *
1096 *FUNCTION:
1097 * This function is called by limProcessSmeMessages() while
1098 * sending SME_SCAN_RSP with scan result to HDD.
1099 *
1100 *LOGIC:
1101 * This function traverses the scan list stored in scan hash table
1102 *
1103 *ASSUMPTIONS:
1104 * NA
1105 *
1106 *NOTE:
1107 * NA
1108 *
1109 * @param pMac - Pointer to Global MAC structure
1110 * @param pDest - Destination pointer
1111 *
1112 * @return None
1113 */
1114
1115void
1116limCopyScanResult(tpAniSirGlobal pMac, tANI_U8 *pDest)
1117{
1118 tLimScanResultNode *ptemp;
1119 tANI_U16 i;
1120 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1121 {
1122 if ((ptemp = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1123 {
1124 while(ptemp)
1125 {
1126 /// Copy entire BSS description including length
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301127 vos_mem_copy( pDest,
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 (tANI_U8 *) &ptemp->bssDescription,
1129 ptemp->bssDescription.length + 2);
1130 pDest += ptemp->bssDescription.length + 2;
1131 ptemp = ptemp->next;
1132 }
1133 }
1134 }
1135} /****** end limCopyScanResult() ******/
1136
1137
1138
1139/**
1140 * limDeleteCachedScanResults()
1141 *
1142 *FUNCTION:
1143 * This function is called by limProcessSmeMessages() upon receiving
1144 * SME_SCAN_REQ with fresh scan result flag set.
1145 *
1146 *LOGIC:
1147 * This function traverses the scan list stored in scan hash table
1148 * and deletes the entries if any
1149 *
1150 *ASSUMPTIONS:
1151 * NA
1152 *
1153 *NOTE:
1154 * NA
1155 *
1156 * @param pMac - Pointer to Global MAC structure
1157 * @return None
1158 */
1159
1160void
1161limDeleteCachedScanResults(tpAniSirGlobal pMac)
1162{
1163 tLimScanResultNode *pNode, *pNextNode;
1164 tANI_U16 i;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301165
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1167 {
1168 if ((pNode = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1169 {
1170 while (pNode)
1171 {
1172 pNextNode = pNode->next;
1173
1174 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301175 vos_mem_free(pNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001176
1177 pNode = pNextNode;
1178 }
1179 }
1180 }
1181
1182 pMac->lim.gLimSmeScanResultLength = 0;
1183} /****** end limDeleteCachedScanResults() ******/
1184
1185
1186
1187/**
1188 * limReInitScanResults()
1189 *
1190 *FUNCTION:
1191 * This function is called delete exisiting scan results
1192 * and initialize the scan hash table
1193 *
1194 *LOGIC:
1195 *
1196 *ASSUMPTIONS:
1197 * NA
1198 *
1199 *NOTE:
1200 * NA
1201 *
1202 * @param pMac - Pointer to Global MAC structure
1203 * @return None
1204 */
1205
1206void
1207limReInitScanResults(tpAniSirGlobal pMac)
1208{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301209 limLog(pMac, LOG1, FL("Re initialize scan hash table."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 limDeleteCachedScanResults(pMac);
1211 limInitHashTable(pMac);
1212
1213 // !!LAC - need to clear out the global scan result length
1214 // since the list was just purged from the hash table.
1215 pMac->lim.gLimMlmScanResultLength = 0;
1216
1217} /****** end limReInitScanResults() ******/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001218#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1219/**
1220 * limDeleteCachedLfrScanResults()
1221 *
1222 *FUNCTION:
1223 * This function is called by limProcessSmeMessages() upon receiving
1224 * SME_SCAN_REQ with flush scan result flag set for LFR.
1225 *
1226 *LOGIC:
1227 * This function traverses the scan list stored in lfr scan hash
1228 * table and deletes the entries if any
1229 *
1230 *ASSUMPTIONS:
1231 * NA
1232 *
1233 *NOTE:
1234 * NA
1235 *
1236 * @param pMac - Pointer to Global MAC structure
1237 * @return None
1238 */
1239
1240void
1241limDeleteCachedLfrScanResults(tpAniSirGlobal pMac)
1242{
1243 tLimScanResultNode *pNode, *pNextNode;
1244 tANI_U16 i;
1245 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1246 {
1247 if ((pNode = pMac->lim.gLimCachedLfrScanHashTable[i]) != NULL)
1248 {
1249 while (pNode)
1250 {
1251 pNextNode = pNode->next;
1252
1253 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301254 vos_mem_free(pNode);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001255
1256 pNode = pNextNode;
1257 }
1258 }
1259 }
1260
1261 pMac->lim.gLimSmeLfrScanResultLength = 0;
1262} /****** end limDeleteCachedLfrScanResults() ******/
1263
1264
1265
1266/**
1267 * limReInitLfrScanResults()
1268 *
1269 *FUNCTION:
1270 * This function is called delete exisiting scan results
1271 * and initialize the lfr scan hash table
1272 *
1273 *LOGIC:
1274 *
1275 *ASSUMPTIONS:
1276 * NA
1277 *
1278 *NOTE:
1279 * NA
1280 *
1281 * @param pMac - Pointer to Global MAC structure
1282 * @return None
1283 */
1284
1285void
1286limReInitLfrScanResults(tpAniSirGlobal pMac)
1287{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301288 limLog(pMac, LOG1, FL("Re initialize lfr scan hash table."));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001289 limDeleteCachedLfrScanResults(pMac);
1290 limInitLfrHashTable(pMac);
1291
1292 // !!LAC - need to clear out the global scan result length
1293 // since the list was just purged from the hash table.
1294 pMac->lim.gLimMlmLfrScanResultLength = 0;
1295
1296} /****** end limReInitLfrScanResults() ******/
1297#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD