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