blob: 8f817f66ecfb76ee8f4285146965d3584b22b722 [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
46
47
48
49/**
50 * limDeactiveMinChannelTimerDuringScan()
51 *
52 *FUNCTION:
53 * This function is called during scan upon receiving
54 * Beacon/Probe Response frame to deactivate MIN channel
55 * timer if running.
56 *
57 * This function should be called only when pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE
58 *
59 *LOGIC:
60 *
61 *ASSUMPTIONS:
62 * NA
63 *
64 *NOTE:
65 * NA
66 *
67 * @param pMac - Pointer to Global MAC structure
68 *
69 * @return eSIR_SUCCESS in case of success
70 */
71
72tANI_U32
73limDeactivateMinChannelTimerDuringScan(tpAniSirGlobal pMac)
74{
75 if ((pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) && (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE))
76 {
77 /**
78 * Beacon/Probe Response is received during active scanning.
79 * Deactivate MIN channel timer if running.
80 */
81
82 limDeactivateAndChangeTimer(pMac,eLIM_MIN_CHANNEL_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -070083 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_MAX_CHANNEL_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -070084 if (tx_timer_activate(&pMac->lim.limTimers.gLimMaxChannelTimer)
85 == TX_TIMER_ERROR)
86 {
87 /// Could not activate max channel timer.
88 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -070089 limLog(pMac,LOGP, FL("could not activate max channel timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070090
91 limCompleteMlmScan(pMac, eSIR_SME_RESOURCES_UNAVAILABLE);
92 return TX_TIMER_ERROR;
93 }
94 }
95 return eSIR_SUCCESS;
96} /*** end limDeactivateMinChannelTimerDuringScan() ***/
97
98
99
100/**
101 * limCollectBssDescription()
102 *
103 *FUNCTION:
104 * This function is called during scan upon receiving
105 * Beacon/Probe Response frame to check if the received
106 * frame matches scan criteria, collect BSS description
107 * and add it to cached scan results.
108 *
109 *LOGIC:
110 *
111 *ASSUMPTIONS:
112 * NA
113 *
114 *NOTE:
115 * NA
116 *
117 * @param pMac - Pointer to Global MAC structure
118 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
119 * @param pRxPacketInfo - Pointer to Received frame's BD
120 * ---------if defined WLAN_FEATURE_VOWIFI------
121 * @param fScanning - flag to indicate if it is during scan.
122 * ---------------------------------------------
123 *
124 * @return None
125 */
126#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530127eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700128limCollectBssDescription(tpAniSirGlobal pMac,
129 tSirBssDescription *pBssDescr,
130 tpSirProbeRespBeacon pBPR,
131 tANI_U8 *pRxPacketInfo,
132 tANI_U8 fScanning)
133#else
Kiet Lam623403f2013-10-21 20:29:40 +0530134eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700135limCollectBssDescription(tpAniSirGlobal pMac,
136 tSirBssDescription *pBssDescr,
137 tpSirProbeRespBeacon pBPR,
138 tANI_U8 *pRxPacketInfo)
139#endif
140{
141 tANI_U8 *pBody;
142 tANI_U32 ieLen = 0;
143 tpSirMacMgmtHdr pHdr;
144 tANI_U8 channelNum;
145 tANI_U8 rxChannel;
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700146 tANI_U8 rfBand = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700147
148 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800149 VOS_ASSERT(WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) >= SIR_MAC_B_PR_SSID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) - SIR_MAC_B_PR_SSID_OFFSET;
151 rxChannel = WDA_GET_RX_CH(pRxPacketInfo);
152 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700153 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700154
Kiet Lam623403f2013-10-21 20:29:40 +0530155 /**
156 * Drop all the beacons and probe response without P2P IE during P2P search
157 */
158 if (NULL != pMac->lim.gpLimMlmScanReq && pMac->lim.gpLimMlmScanReq->p2pSearch)
159 {
160 if (NULL == limGetP2pIEPtr(pMac, (pBody + SIR_MAC_B_PR_SSID_OFFSET), ieLen))
161 {
162 limLog( pMac, LOG3, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHdr->bssId));
163 return eHAL_STATUS_FAILURE;
164 }
165 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700166
167 /**
168 * Length of BSS desription is without length of
169 * length itself and length of pointer
170 * that holds the next BSS description
171 */
172 pBssDescr->length = (tANI_U16)(
173 sizeof(tSirBssDescription) - sizeof(tANI_U16) -
174 sizeof(tANI_U32) + ieLen);
175
176 // Copy BSS Id
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530177 vos_mem_copy((tANI_U8 *) &pBssDescr->bssId,
178 (tANI_U8 *) pHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700179 sizeof(tSirMacAddr));
180
181 // Copy Timestamp, Beacon Interval and Capability Info
182 pBssDescr->scanSysTimeMsec = vos_timer_get_system_time();
183
184 pBssDescr->timeStamp[0] = pBPR->timeStamp[0];
185 pBssDescr->timeStamp[1] = pBPR->timeStamp[1];
186 pBssDescr->beaconInterval = pBPR->beaconInterval;
187 pBssDescr->capabilityInfo = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
188
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +0530189 if(!pBssDescr->beaconInterval )
190 {
191 limLog(pMac, LOGW,
192 FL("Beacon Interval is ZERO, making it to default 100 "
193 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->bssId));
194 pBssDescr->beaconInterval= 100;
195 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 /*
197 * There is a narrow window after Channel Switch msg is sent to HAL and before the AGC is shut
198 * down and beacons/Probe Rsps can trickle in and we may report the incorrect channel in 5Ghz
199 * band, so not relying on the 'last Scanned Channel' stored in LIM.
200 * Instead use the value returned by RXP in BD. This the the same value which HAL programs into
201 * RXP before every channel switch.
202 * Right now there is a problem in 5Ghz, where we are receiving beacons from a channel different from
203 * the currently scanned channel. so incorrect channel is reported to CSR and association does not happen.
204 * So for now we keep on looking for the channel info in the beacon (DSParamSet IE OR HT Info IE), and only if it
205 * is not present in the beacon, we go for the channel info present in RXP.
206 * 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.
207 * So The problem of incorrect channel reporting in 5Ghz will still remain for 11a devices.
208 */
209 pBssDescr->channelId = limGetChannelFromBeacon(pMac, pBPR);
210
211 if (pBssDescr->channelId == 0)
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700212 {
213 /* If the channel Id is not retrieved from Beacon, extract the channel from BD */
214 /* Unmapped the channel.This We have to do since we have done mapping in the hal to
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 overcome the limitation of RXBD of not able to accomodate the bigger channel number.*/
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700216 if ((!rfBand) || IS_5G_BAND(rfBand))
217 {
218 rxChannel = limUnmapChannel(rxChannel);
219 }
220 if (!rxChannel)
221 {
222 rxChannel = pMac->lim.gLimCurrentScanChannelId;
223 }
224 pBssDescr->channelId = rxChannel;
225 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700226
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530227 pBssDescr->channelIdSelf = pBssDescr->channelId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 //set the network type in bss description
229 channelNum = pBssDescr->channelId;
230 pBssDescr->nwType = limGetNwType(pMac, channelNum, SIR_MAC_MGMT_FRAME, pBPR);
231
232 pBssDescr->aniIndicator = pBPR->propIEinfo.aniIndicator;
233
234 // Copy RSSI & SINR from BD
235
236 PELOG4(limLog(pMac, LOG4, "***********BSS Description for BSSID:*********** ");
237 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pBssDescr->bssId, 6 );
238 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG4, (tANI_U8*)pRxPacketInfo, 36 );)
239
240 pBssDescr->rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo);
241
242 //SINR no longer reported by HW
243 pBssDescr->sinr = 0;
244
245 pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
246
247#if defined WLAN_FEATURE_VOWIFI
248 if( fScanning )
249 {
250 rrmGetStartTSF( pMac, pBssDescr->startTSF );
251 pBssDescr->parentTSF = WDA_GET_RX_TIMESTAMP(pRxPacketInfo);
252 }
253#endif
254
255#ifdef WLAN_FEATURE_VOWIFI_11R
256 // MobilityDomain
257 pBssDescr->mdie[0] = 0;
258 pBssDescr->mdie[1] = 0;
259 pBssDescr->mdie[2] = 0;
260 pBssDescr->mdiePresent = FALSE;
261 // If mdie is present in the probe resp we
262 // fill it in the bss description
263 if( pBPR->mdiePresent)
264 {
265 pBssDescr->mdiePresent = TRUE;
266 pBssDescr->mdie[0] = pBPR->mdie[0];
267 pBssDescr->mdie[1] = pBPR->mdie[1];
268 pBssDescr->mdie[2] = pBPR->mdie[2];
269 }
270#endif
271
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800272#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 pBssDescr->QBSSLoad_present = FALSE;
274 pBssDescr->QBSSLoad_avail = 0;
275 if( pBPR->QBSSLoad.present)
276 {
277 pBssDescr->QBSSLoad_present = TRUE;
278 pBssDescr->QBSSLoad_avail = pBPR->QBSSLoad.avail;
279 }
280#endif
281 // Copy IE fields
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530282 vos_mem_copy((tANI_U8 *) &pBssDescr->ieFields,
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 pBody + SIR_MAC_B_PR_SSID_OFFSET,
284 ieLen);
285
286 //sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGW, (tANI_U8 *) pBssDescr, pBssDescr->length + 2 );
287 limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700288 FL("Collected BSS Description for Channel(%1d), length(%u), aniIndicator(%d), IE Fields(%u)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 pBssDescr->channelId,
290 pBssDescr->length,
291 pBssDescr->aniIndicator,
292 ieLen );
293
Kiet Lam623403f2013-10-21 20:29:40 +0530294 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700295} /*** end limCollectBssDescription() ***/
296
297/**
298 * limIsScanRequestedSSID()
299 *
300 *FUNCTION:
301 * This function is called during scan upon receiving
302 * Beacon/Probe Response frame to check if the received
303 * SSID is present in the list of requested SSIDs in scan
304 *
305 *LOGIC:
306 *
307 *ASSUMPTIONS:
308 * NA
309 *
310 *NOTE:
311 * NA
312 *
313 * @param pMac - Pointer to Global MAC structure
314 * @param ssId - SSID Received in beacons/Probe responses that is compared against the
315 requeusted SSID in scan list
316 * ---------------------------------------------
317 *
318 * @return boolean - TRUE if SSID is present in requested list, FALSE otherwise
319 */
320
321tANI_BOOLEAN limIsScanRequestedSSID(tpAniSirGlobal pMac, tSirMacSSid *ssId)
322{
323 tANI_U8 i = 0;
324
325 for (i = 0; i < pMac->lim.gpLimMlmScanReq->numSsid; i++)
326 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530327 if ( eANI_BOOLEAN_TRUE == vos_mem_compare((tANI_U8 *) ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 (tANI_U8 *) &pMac->lim.gpLimMlmScanReq->ssId[i],
329 (tANI_U8) (pMac->lim.gpLimMlmScanReq->ssId[i].length + 1)))
330 {
331 return eANI_BOOLEAN_TRUE;
332 }
333 }
334 return eANI_BOOLEAN_FALSE;
335}
336
337/**
338 * limCheckAndAddBssDescription()
339 *
340 *FUNCTION:
341 * This function is called during scan upon receiving
342 * Beacon/Probe Response frame to check if the received
343 * frame matches scan criteria, collect BSS description
344 * and add it to cached scan results.
345 *
346 *LOGIC:
347 *
348 *ASSUMPTIONS:
349 * NA
350 *
351 *NOTE:
352 * NA
353 *
354 * @param pMac - Pointer to Global MAC structure
355 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
356 * @param pRxPacketInfo - Pointer to Received frame's BD
357 * @param fScanning - boolean to indicate whether the BSS is from current scan or just happen to receive a beacon
358 *
359 * @return None
360 */
361
362void
363limCheckAndAddBssDescription(tpAniSirGlobal pMac,
364 tpSirProbeRespBeacon pBPR,
365 tANI_U8 *pRxPacketInfo,
366 tANI_BOOLEAN fScanning,
367 tANI_U8 fProbeRsp)
368{
369 tLimScanResultNode *pBssDescr;
370 tANI_U32 frameLen, ieLen = 0;
371 tANI_U8 rxChannelInBeacon = 0;
372 eHalStatus status;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700373 tANI_U8 dontUpdateAll = 0;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700374 tANI_U8 rfBand = 0;
375 tANI_U8 rxChannelInBD = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 tSirMacAddr bssid = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
378 tANI_BOOLEAN fFound = FALSE;
379 tpSirMacDataHdr3a pHdr;
380
381 pHdr = WDA_GET_RX_MPDUHEADER3A((tANI_U8 *)pRxPacketInfo);
382
383 //Checking if scanning for a particular BSSID
384 if ((fScanning) && (pMac->lim.gpLimMlmScanReq))
385 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530386 fFound = vos_mem_compare(pHdr->addr3, &pMac->lim.gpLimMlmScanReq->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 if (!fFound)
388 {
389 if ((pMac->lim.gpLimMlmScanReq->p2pSearch) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530390 (vos_mem_compare(pBPR->P2PProbeRes.P2PDeviceInfo.P2PDeviceAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 &pMac->lim.gpLimMlmScanReq->bssId, 6)))
392 {
393 fFound = eANI_BOOLEAN_TRUE;
394 }
395 }
396 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700397
398 /**
399 * Compare SSID with the one sent in
400 * Probe Request frame, if any.
401 * If they don't match, ignore the
402 * Beacon frame.
403 * pMac->lim.gLimMlmScanReq->ssId.length == 0
404 * indicates Broadcast SSID.
405 * When gLimReturnAfterFirstMatch is set, it means the scan has to match
406 * a SSID (if it is also set). Ignore the other BSS in that case.
407 */
408
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700409#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
410 if (!(WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo)))
411 {
412#endif
413 if ((pMac->lim.gpLimMlmScanReq) &&
414 (((fScanning) &&
415 ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) &&
416 (pMac->lim.gpLimMlmScanReq->numSsid) &&
417 !limIsScanRequestedSSID(pMac, &pBPR->ssId)) ||
418 (!fFound && (pMac->lim.gpLimMlmScanReq &&
419 pMac->lim.gpLimMlmScanReq->bssId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530420 !vos_mem_compare(bssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700421 &pMac->lim.gpLimMlmScanReq->bssId, 6))))
Jeff Johnson295189b2012-06-20 16:38:30 -0700422 {
423 /**
424 * Received SSID does not match with
425 * the one we're scanning for.
426 * Ignore received Beacon frame
427 */
428
429 return;
430 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700431#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
432 }
433#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700434
435 /* There is no point in caching & reporting the scan results for APs
436 * which are in the process of switching the channel. So, we are not
437 * caching the scan results for APs which are adverzing the channel-switch
438 * element in their beacons and probe responses.
439 */
440 if(pBPR->channelSwitchPresent)
441 {
442 return;
443 }
444
445 /* If beacon/probe resp DS param channel does not match with
446 * RX BD channel then don't save the results. It might be a beacon
447 * from another channel heard as noise on the current scanning channel
448 */
449
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700450 if ((pBPR->dsParamsPresent) || (pBPR->HTInfo.present))
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 {
452 /* This means that we are in 2.4GHz mode or 5GHz 11n mode */
453 rxChannelInBeacon = limGetChannelFromBeacon(pMac, pBPR);
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700454 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
455 rxChannelInBD = WDA_GET_RX_CH(pRxPacketInfo);
456
457 if ((!rfBand) || IS_5G_BAND(rfBand))
Jeff Johnson295189b2012-06-20 16:38:30 -0700458 {
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700459 rxChannelInBD = limUnmapChannel(rxChannelInBD);
460 }
461
462 if(rxChannelInBD != rxChannelInBeacon)
463 {
464 /* BCAST Frame, if CH do not match, Drop */
465 if(WDA_IS_RX_BCAST(pRxPacketInfo))
466 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700467 limLog(pMac, LOG3, FL("Beacon/Probe Rsp dropped. Channel in BD %d. "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700468 "Channel in beacon" " %d"),
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700469 WDA_GET_RX_CH(pRxPacketInfo),limGetChannelFromBeacon(pMac, pBPR));
470 return;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700471 }
472 /* Unit cast frame, Probe RSP, do not drop */
473 else
474 {
475 dontUpdateAll = 1;
476 limLog(pMac, LOG3, FL("SSID %s, CH in ProbeRsp %d, CH in BD %d, miss-match, Do Not Drop"),
477 pBPR->ssId.ssId,
478 rxChannelInBeacon,
479 WDA_GET_RX_CH(pRxPacketInfo));
480 WDA_GET_RX_CH(pRxPacketInfo) = rxChannelInBeacon;
481 }
482 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 }
484
485 /**
486 * Allocate buffer to hold BSS description from
487 * received Beacon frame.
488 * Include size of fixed fields and IEs length
489 */
490
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800491 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
492 if (ieLen <= SIR_MAC_B_PR_SSID_OFFSET)
493 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700494 limLog(pMac, LOGP,
495 FL("RX packet has invalid length %d"), ieLen);
496 return;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800497 }
498
499 ieLen -= SIR_MAC_B_PR_SSID_OFFSET;
500
501 frameLen = sizeof(tLimScanResultNode) + ieLen - sizeof(tANI_U32); //Sizeof(tANI_U32) is for ieFields[1]
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530503 pBssDescr = vos_mem_malloc(frameLen);
504 if ( NULL == pBssDescr )
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 {
506 // Log error
507 limLog(pMac, LOGP,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530508 FL("call for AllocateMemory failed for storing BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700509
510 return;
511 }
512
513 // In scan state, store scan result.
514#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530515 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 pBPR, pRxPacketInfo, fScanning);
Kiet Lam623403f2013-10-21 20:29:40 +0530517 if (eHAL_STATUS_SUCCESS != status)
518 {
519 goto last;
520 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700521#else
Kiet Lam623403f2013-10-21 20:29:40 +0530522 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 pBPR, pRxPacketInfo);
Kiet Lam623403f2013-10-21 20:29:40 +0530524 if (eHAL_STATUS_SUCCESS != status)
525 {
526 goto last;
527 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700528#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 pBssDescr->bssDescription.fProbeRsp = fProbeRsp;
530
531 pBssDescr->next = NULL;
532
533 /**
534 * Depending on whether to store unique or all
535 * scan results, pass hash update/add parameter
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700536 * For LFR candidates just add them on it's own cache
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 */
538
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700539#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
540 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
541 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800542 limLog(pMac, LOG2, FL(" pHdr->addr1:"MAC_ADDRESS_STR),
543 MAC_ADDR_ARRAY(pHdr->addr1));
544 limLog(pMac, LOG2, FL(" pHdr->addr2:"MAC_ADDRESS_STR),
545 MAC_ADDR_ARRAY(pHdr->addr2));
546 limLog(pMac, LOG2, FL(" pHdr->addr3:"MAC_ADDRESS_STR),
547 MAC_ADDR_ARRAY(pHdr->addr3));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700548 limLog( pMac, LOG2, FL("Save this entry in LFR cache"));
549 status = limLookupNaddLfrHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
550 }
551 else
552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700553 //If it is not scanning, only save unique results
554 if (pMac->lim.gLimReturnUniqueResults || (!fScanning))
555 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700556 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_UPDATE, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 }
558 else
559 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700560 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 }
562
563 if(fScanning)
564 {
565 if ((pBssDescr->bssDescription.channelId <= 14) &&
566 (pMac->lim.gLimReturnAfterFirstMatch & 0x40) &&
567 pBPR->countryInfoPresent)
568 pMac->lim.gLim24Band11dScanDone = 1;
569
570 if ((pBssDescr->bssDescription.channelId > 14) &&
571 (pMac->lim.gLimReturnAfterFirstMatch & 0x80) &&
572 pBPR->countryInfoPresent)
573 pMac->lim.gLim50Band11dScanDone = 1;
574
575 if ( ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) ||
576 ( pMac->lim.gLim24Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x40 ) ) ||
Gopichand Nakkala48b4d7e2013-03-06 23:34:16 +0530577 ( pMac->lim.gLim50Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x80 ) ) ||
578 fFound )
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 {
580 /**
581 * Stop scanning and return the BSS description(s)
582 * collected so far.
583 */
584 limLog(pMac,
585 LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700586 FL("Completed scan: 24Band11dScan = %d, 50Band11dScan = %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 pMac->lim.gLim24Band11dScanDone,
588 pMac->lim.gLim50Band11dScanDone);
589
590 //Need to disable the timers. If they fire, they will send END_SCAN
591 //while we already send FINISH_SCAN here. This may mess up the gLimHalScanState
592 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
593 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
594 //Set the resume channel to Any valid channel (invalid).
595 //This will instruct HAL to set it to any previous valid channel.
596 peSetResumeChannel(pMac, 0, 0);
597 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
598 //limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
599 }
600 }//(eANI_BOOLEAN_TRUE == fScanning)
601
Kiet Lam623403f2013-10-21 20:29:40 +0530602last:
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 if( eHAL_STATUS_SUCCESS != status )
604 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530605 vos_mem_free( pBssDescr );
Jeff Johnson295189b2012-06-20 16:38:30 -0700606 }
Kiet Lam623403f2013-10-21 20:29:40 +0530607 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700608} /****** end limCheckAndAddBssDescription() ******/
609
610
611
612/**
613 * limScanHashFunction()
614 *
615 *FUNCTION:
616 * This function is called during scan hash entry operations
617 *
618 *LOGIC:
619 *
620 *ASSUMPTIONS:
621 * NA
622 *
623 *NOTE:
624 * NA
625 *
626 * @param bssId - Received BSSid
627 *
628 * @return Hash index
629 */
630
631tANI_U8
632limScanHashFunction(tSirMacAddr bssId)
633{
634 tANI_U16 i, hash = 0;
635
636 for (i = 0; i < sizeof(tSirMacAddr); i++)
637 hash += bssId[i];
638
639 return hash % LIM_MAX_NUM_OF_SCAN_RESULTS;
640} /****** end limScanHashFunction() ******/
641
642
643
644/**
645 * limInitHashTable()
646 *
647 *FUNCTION:
648 * This function is called upon receiving SME_START_REQ
649 * to initialize global cached scan hash table
650 *
651 *LOGIC:
652 *
653 *ASSUMPTIONS:
654 * NA
655 *
656 *NOTE:
657 * NA
658 *
659 * @param pMac - Pointer to Global MAC structure
660 * @return None
661 */
662
663void
664limInitHashTable(tpAniSirGlobal pMac)
665{
666 tANI_U16 i;
667 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
668 pMac->lim.gLimCachedScanHashTable[i] = NULL;
669} /****** end limInitHashTable() ******/
670
671
672
673/**
674 * limLookupNaddHashEntry()
675 *
676 *FUNCTION:
677 * This function is called upon receiving a Beacon or
678 * Probe Response frame during scan phase to store
679 * received BSS description into scan result hash table.
680 *
681 *LOGIC:
682 *
683 *ASSUMPTIONS:
684 * NA
685 *
686 *NOTE:
687 * NA
688 *
689 * @param pMac - Pointer to Global MAC structure
690 * @param pBssDescr - Pointer to BSS description to be
691 * added to the scan result hash table.
692 * @param action - Indicates action to be performed
693 * when same BSS description is found. This is
694 * dependent on whether unique scan result to
695 * be stored or not.
696 *
697 * @return None
698 */
699
700eHalStatus
701limLookupNaddHashEntry(tpAniSirGlobal pMac,
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700702 tLimScanResultNode *pBssDescr, tANI_U8 action,
703 tANI_U8 dontUpdateAll)
Jeff Johnson295189b2012-06-20 16:38:30 -0700704{
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700705 tANI_U8 index, ssidLen = 0;
706 tANI_U8 found = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 tLimScanResultNode *ptemp, *pprev;
708 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
709 int idx, len;
710 tANI_U8 *pbIe;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700711 tANI_S8 rssi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700712
713 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
714 ptemp = pMac->lim.gLimCachedScanHashTable[index];
715
716 //ieFields start with TLV of SSID IE
717 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
718 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
719
720 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
721 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700722 //For infrastructure, check BSSID and SSID. For IBSS, check more
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530724 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
725 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 (tANI_U8 *) ptemp->bssDescription.bssId,
727 sizeof(tSirMacAddr))) && //matching BSSID
Jeff Johnsone7245742012-09-05 17:12:55 -0700728 (pBssDescr->bssDescription.channelId ==
729 ptemp->bssDescription.channelId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530730 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
732 (tANI_U8) (ssidLen + 1)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700733 ((pSirCapTemp->ess) || //we are done for infrastructure
734 //For IBSS, nwType and channelId
735 (((pBssDescr->bssDescription.nwType ==
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 ptemp->bssDescription.nwType) &&
737 (pBssDescr->bssDescription.channelId ==
738 ptemp->bssDescription.channelId))))
739 )
740 {
741 // Found the same BSS description
742 if (action == LIM_HASH_UPDATE)
743 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700744 if(dontUpdateAll)
745 {
746 rssi = ptemp->bssDescription.rssi;
747 }
748
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
750 {
751 //We get a different, save the old frame WSC IE if it is there
752 idx = 0;
753 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
754 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
755 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
756 //Save WPS IE if it exists
757 pBssDescr->bssDescription.WscIeLen = 0;
758 while(idx < len)
759 {
760 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
761 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
762 {
763 //Found it
764 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
765 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530766 vos_mem_copy(pBssDescr->bssDescription.WscIeProbeRsp,
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 pbIe, pbIe[1] + 2);
768 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
769 }
770 break;
771 }
772 idx += pbIe[1] + 2;
773 pbIe += pbIe[1] + 2;
774 }
775 }
776
777
778 if(NULL != pMac->lim.gpLimMlmScanReq)
779 {
780 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
781 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
782 &pBssDescr->bssDescription.ieFields + 1))))
783 return eHAL_STATUS_FAILURE;
784 }
785
786 // Delete this entry
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700787 if (ptemp == pMac->lim.gLimCachedScanHashTable[index])
788 pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 else
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700790 pprev->next = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700791
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700792 pMac->lim.gLimMlmScanResultLength -=
793 ptemp->bssDescription.length + sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -0700794
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530795 vos_mem_free(ptemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 }
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700797 found = true;
798 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 }
800 }
801
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700802 //for now, only rssi, we can add more if needed
Madan Mohan Koyyalamudi3e9f2022012-12-04 16:34:19 -0800803 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700804 {
805 pBssDescr->bssDescription.rssi = rssi;
806 }
807
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 // Add this BSS description at same index
809 if (pprev == pMac->lim.gLimCachedScanHashTable[index])
810 {
811 pBssDescr->next = pMac->lim.gLimCachedScanHashTable[index];
812 pMac->lim.gLimCachedScanHashTable[index] = pBssDescr;
813 }
814 else
815 {
816 pBssDescr->next = pprev->next;
817 pprev->next = pBssDescr;
818 }
819 pMac->lim.gLimMlmScanResultLength +=
820 pBssDescr->bssDescription.length + sizeof(tANI_U16);
821
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700822 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 pBssDescr->bssDescription.length,
824 pMac->lim.gLimMlmScanResultLength);
825 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
826
827 // Send new BSS found indication to HDD if CFG option is set
828 if (!found) limSendSmeNeighborBssInd(pMac, pBssDescr);
829
830 //
831 // TODO: IF applicable, do we need to send:
832 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
833 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
834 //
835 return eHAL_STATUS_SUCCESS;
836}
837
838
839
840/**
841 * limDeleteHashEntry()
842 *
843 *FUNCTION:
844 * This function is called upon to delete
845 * a BSS description from scan result hash table.
846 *
847 *LOGIC:
848 *
849 *ASSUMPTIONS:
850 * NA
851 *
852 *NOTE:
853 * Yet to find the utility of the function
854 *
855 * @param pBssDescr - Pointer to BSS description to be
856 * deleted from the scan result hash table.
857 *
858 * @return None
859 */
860
861void limDeleteHashEntry(tLimScanResultNode *pBssDescr)
862{
863} /****** end limDeleteHashEntry() ******/
864
865
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700866#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
867/**
868 * limInitLfrHashTable()
869 *
870 *FUNCTION:
871 * This function is called upon receiving SME_START_REQ
872 * to initialize global cached Lfr scan hash table
873 *
874 *LOGIC:
875 *
876 *ASSUMPTIONS:
877 * NA
878 *
879 *NOTE:
880 * NA
881 *
882 * @param pMac - Pointer to Global MAC structure
883 * @return None
884 */
885
886void
887limInitLfrHashTable(tpAniSirGlobal pMac)
888{
889 tANI_U16 i;
890 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
891 pMac->lim.gLimCachedLfrScanHashTable[i] = NULL;
892} /****** end limInitLfrHashTable() ******/
893
894
895
896/**
897 * limLookupNaddLfrHashEntry()
898 *
899 *FUNCTION:
900 * This function is called upon receiving a Beacon or
901 * Probe Response frame during Lfr scan phase from FW to store
902 * received BSS description into Lfr scan result hash table.
903 *
904 *LOGIC:
905 *
906 *ASSUMPTIONS:
907 * NA
908 *
909 *NOTE:
910 * NA
911 *
912 * @param pMac - Pointer to Global MAC structure
913 * @param pBssDescr - Pointer to BSS description to be
914 * added to the Lfr scan result hash table.
915 * @param action - Indicates action to be performed
916 * when same BSS description is found. This is
917 * dependent on whether unique scan result to
918 * be stored or not.
919 *
920 * @return None
921 */
922
923eHalStatus
924limLookupNaddLfrHashEntry(tpAniSirGlobal pMac,
925 tLimScanResultNode *pBssDescr, tANI_U8 action,
926 tANI_U8 dontUpdateAll)
927{
928 tANI_U8 index, ssidLen = 0;
929 tLimScanResultNode *ptemp, *pprev;
930 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
931 int idx, len;
932 tANI_U8 *pbIe;
933 tANI_S8 rssi = 0;
934
935 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
936 ptemp = pMac->lim.gLimCachedLfrScanHashTable[index];
937
938 //ieFields start with TLV of SSID IE
939 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
940 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
941
942 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
943 {
944 //For infrastructure, check BSSID and SSID. For IBSS, check more
945 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530946 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
947 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700948 (tANI_U8 *) ptemp->bssDescription.bssId,
949 sizeof(tSirMacAddr))) && //matching BSSID
950 (pBssDescr->bssDescription.channelId ==
951 ptemp->bssDescription.channelId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530952 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700953 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
954 (tANI_U8) (ssidLen + 1)) &&
955 ((pSirCapTemp->ess) || //we are done for infrastructure
956 //For IBSS, nwType and channelId
957 (((pBssDescr->bssDescription.nwType ==
958 ptemp->bssDescription.nwType) &&
959 (pBssDescr->bssDescription.channelId ==
960 ptemp->bssDescription.channelId))))
961 )
962 {
963 // Found the same BSS description
964 if (action == LIM_HASH_UPDATE)
965 {
966 if(dontUpdateAll)
967 {
968 rssi = ptemp->bssDescription.rssi;
969 }
970
971 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
972 {
973 //We get a different, save the old frame WSC IE if it is there
974 idx = 0;
975 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
976 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
977 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
978 //Save WPS IE if it exists
979 pBssDescr->bssDescription.WscIeLen = 0;
980 while(idx < len)
981 {
982 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
983 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) &&
984 (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
985 {
986 //Found it
987 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
988 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530989 vos_mem_copy( pBssDescr->bssDescription.WscIeProbeRsp,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700990 pbIe, pbIe[1] + 2);
991 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
992 }
993 break;
994 }
995 idx += pbIe[1] + 2;
996 pbIe += pbIe[1] + 2;
997 }
998 }
999
1000
1001 if(NULL != pMac->lim.gpLimMlmScanReq)
1002 {
1003 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
1004 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
1005 &pBssDescr->bssDescription.ieFields + 1))))
1006 return eHAL_STATUS_FAILURE;
1007 }
1008
1009 // Delete this entry
1010 if (ptemp == pMac->lim.gLimCachedLfrScanHashTable[index])
1011 pprev = pMac->lim.gLimCachedLfrScanHashTable[index] = ptemp->next;
1012 else
1013 pprev->next = ptemp->next;
1014
1015 pMac->lim.gLimMlmLfrScanResultLength -=
1016 ptemp->bssDescription.length + sizeof(tANI_U16);
1017
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301018 vos_mem_free(ptemp);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001019 }
1020 break;
1021 }
1022 }
1023
1024 //for now, only rssi, we can add more if needed
1025 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
1026 {
1027 pBssDescr->bssDescription.rssi = rssi;
1028 }
1029
1030 // Add this BSS description at same index
1031 if (pprev == pMac->lim.gLimCachedLfrScanHashTable[index])
1032 {
1033 pBssDescr->next = pMac->lim.gLimCachedLfrScanHashTable[index];
1034 pMac->lim.gLimCachedLfrScanHashTable[index] = pBssDescr;
1035 }
1036 else
1037 {
1038 pBssDescr->next = pprev->next;
1039 pprev->next = pBssDescr;
1040 }
1041 pMac->lim.gLimMlmLfrScanResultLength +=
1042 pBssDescr->bssDescription.length + sizeof(tANI_U16);
1043
1044 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id\n"),
1045 pBssDescr->bssDescription.length,
1046 pMac->lim.gLimMlmLfrScanResultLength);
1047 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
1048
1049 //
1050 // TODO: IF applicable, do we need to send:
1051 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
1052 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
1053 //
1054 return eHAL_STATUS_SUCCESS;
1055}
1056
1057
1058
1059/**
1060 * limDeleteLfrHashEntry()
1061 *
1062 *FUNCTION:
1063 * This function is called upon to delete
1064 * a BSS description from LFR scan result hash table.
1065 *
1066 *LOGIC:
1067 *
1068 *ASSUMPTIONS:
1069 * NA
1070 *
1071 *NOTE:
1072 * Yet to find the utility of the function
1073 *
1074 * @param pBssDescr - Pointer to BSS description to be
1075 * deleted from the LFR scan result hash table.
1076 *
1077 * @return None
1078 */
1079
1080void limDeleteLfrHashEntry(tLimScanResultNode *pBssDescr)
1081{
1082} /****** end limDeleteLfrHashEntry() ******/
1083
1084#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001085
1086/**
1087 * limCopyScanResult()
1088 *
1089 *FUNCTION:
1090 * This function is called by limProcessSmeMessages() while
1091 * sending SME_SCAN_RSP with scan result to HDD.
1092 *
1093 *LOGIC:
1094 * This function traverses the scan list stored in scan hash table
1095 *
1096 *ASSUMPTIONS:
1097 * NA
1098 *
1099 *NOTE:
1100 * NA
1101 *
1102 * @param pMac - Pointer to Global MAC structure
1103 * @param pDest - Destination pointer
1104 *
1105 * @return None
1106 */
1107
1108void
1109limCopyScanResult(tpAniSirGlobal pMac, tANI_U8 *pDest)
1110{
1111 tLimScanResultNode *ptemp;
1112 tANI_U16 i;
1113 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1114 {
1115 if ((ptemp = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1116 {
1117 while(ptemp)
1118 {
1119 /// Copy entire BSS description including length
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301120 vos_mem_copy( pDest,
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 (tANI_U8 *) &ptemp->bssDescription,
1122 ptemp->bssDescription.length + 2);
1123 pDest += ptemp->bssDescription.length + 2;
1124 ptemp = ptemp->next;
1125 }
1126 }
1127 }
1128} /****** end limCopyScanResult() ******/
1129
1130
1131
1132/**
1133 * limDeleteCachedScanResults()
1134 *
1135 *FUNCTION:
1136 * This function is called by limProcessSmeMessages() upon receiving
1137 * SME_SCAN_REQ with fresh scan result flag set.
1138 *
1139 *LOGIC:
1140 * This function traverses the scan list stored in scan hash table
1141 * and deletes the entries if any
1142 *
1143 *ASSUMPTIONS:
1144 * NA
1145 *
1146 *NOTE:
1147 * NA
1148 *
1149 * @param pMac - Pointer to Global MAC structure
1150 * @return None
1151 */
1152
1153void
1154limDeleteCachedScanResults(tpAniSirGlobal pMac)
1155{
1156 tLimScanResultNode *pNode, *pNextNode;
1157 tANI_U16 i;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301158
Jeff Johnson295189b2012-06-20 16:38:30 -07001159 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{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301202 limLog(pMac, LOG1, FL("Re initialize scan hash table."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001203 limDeleteCachedScanResults(pMac);
1204 limInitHashTable(pMac);
1205
1206 // !!LAC - need to clear out the global scan result length
1207 // since the list was just purged from the hash table.
1208 pMac->lim.gLimMlmScanResultLength = 0;
1209
1210} /****** end limReInitScanResults() ******/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001211#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1212/**
1213 * limDeleteCachedLfrScanResults()
1214 *
1215 *FUNCTION:
1216 * This function is called by limProcessSmeMessages() upon receiving
1217 * SME_SCAN_REQ with flush scan result flag set for LFR.
1218 *
1219 *LOGIC:
1220 * This function traverses the scan list stored in lfr scan hash
1221 * table and deletes the entries if any
1222 *
1223 *ASSUMPTIONS:
1224 * NA
1225 *
1226 *NOTE:
1227 * NA
1228 *
1229 * @param pMac - Pointer to Global MAC structure
1230 * @return None
1231 */
1232
1233void
1234limDeleteCachedLfrScanResults(tpAniSirGlobal pMac)
1235{
1236 tLimScanResultNode *pNode, *pNextNode;
1237 tANI_U16 i;
1238 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1239 {
1240 if ((pNode = pMac->lim.gLimCachedLfrScanHashTable[i]) != NULL)
1241 {
1242 while (pNode)
1243 {
1244 pNextNode = pNode->next;
1245
1246 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301247 vos_mem_free(pNode);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001248
1249 pNode = pNextNode;
1250 }
1251 }
1252 }
1253
1254 pMac->lim.gLimSmeLfrScanResultLength = 0;
1255} /****** end limDeleteCachedLfrScanResults() ******/
1256
1257
1258
1259/**
1260 * limReInitLfrScanResults()
1261 *
1262 *FUNCTION:
1263 * This function is called delete exisiting scan results
1264 * and initialize the lfr scan hash table
1265 *
1266 *LOGIC:
1267 *
1268 *ASSUMPTIONS:
1269 * NA
1270 *
1271 *NOTE:
1272 * NA
1273 *
1274 * @param pMac - Pointer to Global MAC structure
1275 * @return None
1276 */
1277
1278void
1279limReInitLfrScanResults(tpAniSirGlobal pMac)
1280{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301281 limLog(pMac, LOG1, FL("Re initialize lfr scan hash table."));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001282 limDeleteCachedLfrScanResults(pMac);
1283 limInitLfrHashTable(pMac);
1284
1285 // !!LAC - need to clear out the global scan result length
1286 // since the list was just purged from the hash table.
1287 pMac->lim.gLimMlmLfrScanResultLength = 0;
1288
1289} /****** end limReInitLfrScanResults() ******/
1290#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD