blob: 8c5149469b6031abbce54bd5e1154752a8a92561 [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
Kiet Lam623403f2013-10-21 20:29:40 +0530142eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700143limCollectBssDescription(tpAniSirGlobal pMac,
144 tSirBssDescription *pBssDescr,
145 tpSirProbeRespBeacon pBPR,
146 tANI_U8 *pRxPacketInfo,
147 tANI_U8 fScanning)
148#else
Kiet Lam623403f2013-10-21 20:29:40 +0530149eHalStatus
Jeff Johnson295189b2012-06-20 16:38:30 -0700150limCollectBssDescription(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
Kiet Lam623403f2013-10-21 20:29:40 +0530170 /**
171 * Drop all the beacons and probe response without P2P IE during P2P search
172 */
173 if (NULL != pMac->lim.gpLimMlmScanReq && pMac->lim.gpLimMlmScanReq->p2pSearch)
174 {
175 if (NULL == limGetP2pIEPtr(pMac, (pBody + SIR_MAC_B_PR_SSID_OFFSET), ieLen))
176 {
177 limLog( pMac, LOG3, MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHdr->bssId));
178 return eHAL_STATUS_FAILURE;
179 }
180 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
182 /**
183 * Length of BSS desription is without length of
184 * length itself and length of pointer
185 * that holds the next BSS description
186 */
187 pBssDescr->length = (tANI_U16)(
188 sizeof(tSirBssDescription) - sizeof(tANI_U16) -
189 sizeof(tANI_U32) + ieLen);
190
191 // Copy BSS Id
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530192 vos_mem_copy((tANI_U8 *) &pBssDescr->bssId,
193 (tANI_U8 *) pHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 sizeof(tSirMacAddr));
195
196 // Copy Timestamp, Beacon Interval and Capability Info
197 pBssDescr->scanSysTimeMsec = vos_timer_get_system_time();
198
199 pBssDescr->timeStamp[0] = pBPR->timeStamp[0];
200 pBssDescr->timeStamp[1] = pBPR->timeStamp[1];
201 pBssDescr->beaconInterval = pBPR->beaconInterval;
202 pBssDescr->capabilityInfo = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
203
204
205 /*
206 * There is a narrow window after Channel Switch msg is sent to HAL and before the AGC is shut
207 * down and beacons/Probe Rsps can trickle in and we may report the incorrect channel in 5Ghz
208 * band, so not relying on the 'last Scanned Channel' stored in LIM.
209 * Instead use the value returned by RXP in BD. This the the same value which HAL programs into
210 * RXP before every channel switch.
211 * Right now there is a problem in 5Ghz, where we are receiving beacons from a channel different from
212 * the currently scanned channel. so incorrect channel is reported to CSR and association does not happen.
213 * So for now we keep on looking for the channel info in the beacon (DSParamSet IE OR HT Info IE), and only if it
214 * is not present in the beacon, we go for the channel info present in RXP.
215 * 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.
216 * So The problem of incorrect channel reporting in 5Ghz will still remain for 11a devices.
217 */
218 pBssDescr->channelId = limGetChannelFromBeacon(pMac, pBPR);
219
220 if (pBssDescr->channelId == 0)
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700221 {
222 /* If the channel Id is not retrieved from Beacon, extract the channel from BD */
223 /* Unmapped the channel.This We have to do since we have done mapping in the hal to
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 overcome the limitation of RXBD of not able to accomodate the bigger channel number.*/
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700225 if ((!rfBand) || IS_5G_BAND(rfBand))
226 {
227 rxChannel = limUnmapChannel(rxChannel);
228 }
229 if (!rxChannel)
230 {
231 rxChannel = pMac->lim.gLimCurrentScanChannelId;
232 }
233 pBssDescr->channelId = rxChannel;
234 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700235
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530236 pBssDescr->channelIdSelf = pBssDescr->channelId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700237 //set the network type in bss description
238 channelNum = pBssDescr->channelId;
239 pBssDescr->nwType = limGetNwType(pMac, channelNum, SIR_MAC_MGMT_FRAME, pBPR);
240
241 pBssDescr->aniIndicator = pBPR->propIEinfo.aniIndicator;
242
243 // Copy RSSI & SINR from BD
244
245 PELOG4(limLog(pMac, LOG4, "***********BSS Description for BSSID:*********** ");
246 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pBssDescr->bssId, 6 );
247 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG4, (tANI_U8*)pRxPacketInfo, 36 );)
248
249 pBssDescr->rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo);
250
251 //SINR no longer reported by HW
252 pBssDescr->sinr = 0;
253
254 pBssDescr->nReceivedTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
255
256#if defined WLAN_FEATURE_VOWIFI
257 if( fScanning )
258 {
259 rrmGetStartTSF( pMac, pBssDescr->startTSF );
260 pBssDescr->parentTSF = WDA_GET_RX_TIMESTAMP(pRxPacketInfo);
261 }
262#endif
263
264#ifdef WLAN_FEATURE_VOWIFI_11R
265 // MobilityDomain
266 pBssDescr->mdie[0] = 0;
267 pBssDescr->mdie[1] = 0;
268 pBssDescr->mdie[2] = 0;
269 pBssDescr->mdiePresent = FALSE;
270 // If mdie is present in the probe resp we
271 // fill it in the bss description
272 if( pBPR->mdiePresent)
273 {
274 pBssDescr->mdiePresent = TRUE;
275 pBssDescr->mdie[0] = pBPR->mdie[0];
276 pBssDescr->mdie[1] = pBPR->mdie[1];
277 pBssDescr->mdie[2] = pBPR->mdie[2];
278 }
279#endif
280
281#ifdef FEATURE_WLAN_CCX
282 pBssDescr->QBSSLoad_present = FALSE;
283 pBssDescr->QBSSLoad_avail = 0;
284 if( pBPR->QBSSLoad.present)
285 {
286 pBssDescr->QBSSLoad_present = TRUE;
287 pBssDescr->QBSSLoad_avail = pBPR->QBSSLoad.avail;
288 }
289#endif
290 // Copy IE fields
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530291 vos_mem_copy((tANI_U8 *) &pBssDescr->ieFields,
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 pBody + SIR_MAC_B_PR_SSID_OFFSET,
293 ieLen);
294
295 //sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGW, (tANI_U8 *) pBssDescr, pBssDescr->length + 2 );
296 limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700297 FL("Collected BSS Description for Channel(%1d), length(%u), aniIndicator(%d), IE Fields(%u)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 pBssDescr->channelId,
299 pBssDescr->length,
300 pBssDescr->aniIndicator,
301 ieLen );
302
Kiet Lam623403f2013-10-21 20:29:40 +0530303 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700304} /*** end limCollectBssDescription() ***/
305
306/**
307 * limIsScanRequestedSSID()
308 *
309 *FUNCTION:
310 * This function is called during scan upon receiving
311 * Beacon/Probe Response frame to check if the received
312 * SSID is present in the list of requested SSIDs in scan
313 *
314 *LOGIC:
315 *
316 *ASSUMPTIONS:
317 * NA
318 *
319 *NOTE:
320 * NA
321 *
322 * @param pMac - Pointer to Global MAC structure
323 * @param ssId - SSID Received in beacons/Probe responses that is compared against the
324 requeusted SSID in scan list
325 * ---------------------------------------------
326 *
327 * @return boolean - TRUE if SSID is present in requested list, FALSE otherwise
328 */
329
330tANI_BOOLEAN limIsScanRequestedSSID(tpAniSirGlobal pMac, tSirMacSSid *ssId)
331{
332 tANI_U8 i = 0;
333
334 for (i = 0; i < pMac->lim.gpLimMlmScanReq->numSsid; i++)
335 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530336 if ( eANI_BOOLEAN_TRUE == vos_mem_compare((tANI_U8 *) ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 (tANI_U8 *) &pMac->lim.gpLimMlmScanReq->ssId[i],
338 (tANI_U8) (pMac->lim.gpLimMlmScanReq->ssId[i].length + 1)))
339 {
340 return eANI_BOOLEAN_TRUE;
341 }
342 }
343 return eANI_BOOLEAN_FALSE;
344}
345
346/**
347 * limCheckAndAddBssDescription()
348 *
349 *FUNCTION:
350 * This function is called during scan upon receiving
351 * Beacon/Probe Response frame to check if the received
352 * frame matches scan criteria, collect BSS description
353 * and add it to cached scan results.
354 *
355 *LOGIC:
356 *
357 *ASSUMPTIONS:
358 * NA
359 *
360 *NOTE:
361 * NA
362 *
363 * @param pMac - Pointer to Global MAC structure
364 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
365 * @param pRxPacketInfo - Pointer to Received frame's BD
366 * @param fScanning - boolean to indicate whether the BSS is from current scan or just happen to receive a beacon
367 *
368 * @return None
369 */
370
371void
372limCheckAndAddBssDescription(tpAniSirGlobal pMac,
373 tpSirProbeRespBeacon pBPR,
374 tANI_U8 *pRxPacketInfo,
375 tANI_BOOLEAN fScanning,
376 tANI_U8 fProbeRsp)
377{
378 tLimScanResultNode *pBssDescr;
379 tANI_U32 frameLen, ieLen = 0;
380 tANI_U8 rxChannelInBeacon = 0;
381 eHalStatus status;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700382 tANI_U8 dontUpdateAll = 0;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700383 tANI_U8 rfBand = 0;
384 tANI_U8 rxChannelInBD = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700385
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 tSirMacAddr bssid = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
387 tANI_BOOLEAN fFound = FALSE;
388 tpSirMacDataHdr3a pHdr;
389
390 pHdr = WDA_GET_RX_MPDUHEADER3A((tANI_U8 *)pRxPacketInfo);
391
392 //Checking if scanning for a particular BSSID
393 if ((fScanning) && (pMac->lim.gpLimMlmScanReq))
394 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530395 fFound = vos_mem_compare(pHdr->addr3, &pMac->lim.gpLimMlmScanReq->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -0700396 if (!fFound)
397 {
398 if ((pMac->lim.gpLimMlmScanReq->p2pSearch) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530399 (vos_mem_compare(pBPR->P2PProbeRes.P2PDeviceInfo.P2PDeviceAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 &pMac->lim.gpLimMlmScanReq->bssId, 6)))
401 {
402 fFound = eANI_BOOLEAN_TRUE;
403 }
404 }
405 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700406
407 /**
408 * Compare SSID with the one sent in
409 * Probe Request frame, if any.
410 * If they don't match, ignore the
411 * Beacon frame.
412 * pMac->lim.gLimMlmScanReq->ssId.length == 0
413 * indicates Broadcast SSID.
414 * When gLimReturnAfterFirstMatch is set, it means the scan has to match
415 * a SSID (if it is also set). Ignore the other BSS in that case.
416 */
417
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700418#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
419 if (!(WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo)))
420 {
421#endif
422 if ((pMac->lim.gpLimMlmScanReq) &&
423 (((fScanning) &&
424 ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) &&
425 (pMac->lim.gpLimMlmScanReq->numSsid) &&
426 !limIsScanRequestedSSID(pMac, &pBPR->ssId)) ||
427 (!fFound && (pMac->lim.gpLimMlmScanReq &&
428 pMac->lim.gpLimMlmScanReq->bssId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530429 !vos_mem_compare(bssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700430 &pMac->lim.gpLimMlmScanReq->bssId, 6))))
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 {
432 /**
433 * Received SSID does not match with
434 * the one we're scanning for.
435 * Ignore received Beacon frame
436 */
437
438 return;
439 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700440#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
441 }
442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700443
444 /* There is no point in caching & reporting the scan results for APs
445 * which are in the process of switching the channel. So, we are not
446 * caching the scan results for APs which are adverzing the channel-switch
447 * element in their beacons and probe responses.
448 */
449 if(pBPR->channelSwitchPresent)
450 {
451 return;
452 }
453
454 /* If beacon/probe resp DS param channel does not match with
455 * RX BD channel then don't save the results. It might be a beacon
456 * from another channel heard as noise on the current scanning channel
457 */
458
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700459 if ((pBPR->dsParamsPresent) || (pBPR->HTInfo.present))
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 {
461 /* This means that we are in 2.4GHz mode or 5GHz 11n mode */
462 rxChannelInBeacon = limGetChannelFromBeacon(pMac, pBPR);
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700463 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
464 rxChannelInBD = WDA_GET_RX_CH(pRxPacketInfo);
465
466 if ((!rfBand) || IS_5G_BAND(rfBand))
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 {
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700468 rxChannelInBD = limUnmapChannel(rxChannelInBD);
469 }
470
471 if(rxChannelInBD != rxChannelInBeacon)
472 {
473 /* BCAST Frame, if CH do not match, Drop */
474 if(WDA_IS_RX_BCAST(pRxPacketInfo))
475 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700476 limLog(pMac, LOG3, FL("Beacon/Probe Rsp dropped. Channel in BD %d. "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700477 "Channel in beacon" " %d"),
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700478 WDA_GET_RX_CH(pRxPacketInfo),limGetChannelFromBeacon(pMac, pBPR));
479 return;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700480 }
481 /* Unit cast frame, Probe RSP, do not drop */
482 else
483 {
484 dontUpdateAll = 1;
485 limLog(pMac, LOG3, FL("SSID %s, CH in ProbeRsp %d, CH in BD %d, miss-match, Do Not Drop"),
486 pBPR->ssId.ssId,
487 rxChannelInBeacon,
488 WDA_GET_RX_CH(pRxPacketInfo));
489 WDA_GET_RX_CH(pRxPacketInfo) = rxChannelInBeacon;
490 }
491 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 }
493
494 /**
495 * Allocate buffer to hold BSS description from
496 * received Beacon frame.
497 * Include size of fixed fields and IEs length
498 */
499
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800500 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
501 if (ieLen <= SIR_MAC_B_PR_SSID_OFFSET)
502 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700503 limLog(pMac, LOGP,
504 FL("RX packet has invalid length %d"), ieLen);
505 return;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800506 }
507
508 ieLen -= SIR_MAC_B_PR_SSID_OFFSET;
509
510 frameLen = sizeof(tLimScanResultNode) + ieLen - sizeof(tANI_U32); //Sizeof(tANI_U32) is for ieFields[1]
Jeff Johnson295189b2012-06-20 16:38:30 -0700511
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530512 pBssDescr = vos_mem_malloc(frameLen);
513 if ( NULL == pBssDescr )
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 {
515 // Log error
516 limLog(pMac, LOGP,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530517 FL("call for AllocateMemory failed for storing BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700518
519 return;
520 }
521
522 // In scan state, store scan result.
523#if defined WLAN_FEATURE_VOWIFI
Kiet Lam623403f2013-10-21 20:29:40 +0530524 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 pBPR, pRxPacketInfo, fScanning);
Kiet Lam623403f2013-10-21 20:29:40 +0530526 if (eHAL_STATUS_SUCCESS != status)
527 {
528 goto last;
529 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700530#else
Kiet Lam623403f2013-10-21 20:29:40 +0530531 status = limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 pBPR, pRxPacketInfo);
Kiet Lam623403f2013-10-21 20:29:40 +0530533 if (eHAL_STATUS_SUCCESS != status)
534 {
535 goto last;
536 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700537#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 pBssDescr->bssDescription.fProbeRsp = fProbeRsp;
539
540 pBssDescr->next = NULL;
541
542 /**
543 * Depending on whether to store unique or all
544 * scan results, pass hash update/add parameter
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700545 * For LFR candidates just add them on it's own cache
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 */
547
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700548#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
549 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
550 {
Arif Hussain24bafea2013-11-15 15:10:03 -0800551 limLog(pMac, LOG2, FL(" pHdr->addr1:"MAC_ADDRESS_STR),
552 MAC_ADDR_ARRAY(pHdr->addr1));
553 limLog(pMac, LOG2, FL(" pHdr->addr2:"MAC_ADDRESS_STR),
554 MAC_ADDR_ARRAY(pHdr->addr2));
555 limLog(pMac, LOG2, FL(" pHdr->addr3:"MAC_ADDRESS_STR),
556 MAC_ADDR_ARRAY(pHdr->addr3));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700557 limLog( pMac, LOG2, FL("Save this entry in LFR cache"));
558 status = limLookupNaddLfrHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
559 }
560 else
561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 //If it is not scanning, only save unique results
563 if (pMac->lim.gLimReturnUniqueResults || (!fScanning))
564 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700565 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_UPDATE, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700566 }
567 else
568 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700569 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_ADD, dontUpdateAll);
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 }
571
572 if(fScanning)
573 {
574 if ((pBssDescr->bssDescription.channelId <= 14) &&
575 (pMac->lim.gLimReturnAfterFirstMatch & 0x40) &&
576 pBPR->countryInfoPresent)
577 pMac->lim.gLim24Band11dScanDone = 1;
578
579 if ((pBssDescr->bssDescription.channelId > 14) &&
580 (pMac->lim.gLimReturnAfterFirstMatch & 0x80) &&
581 pBPR->countryInfoPresent)
582 pMac->lim.gLim50Band11dScanDone = 1;
583
584 if ( ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) ||
585 ( pMac->lim.gLim24Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x40 ) ) ||
Gopichand Nakkala48b4d7e2013-03-06 23:34:16 +0530586 ( pMac->lim.gLim50Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x80 ) ) ||
587 fFound )
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 {
589 /**
590 * Stop scanning and return the BSS description(s)
591 * collected so far.
592 */
593 limLog(pMac,
594 LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700595 FL("Completed scan: 24Band11dScan = %d, 50Band11dScan = %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 pMac->lim.gLim24Band11dScanDone,
597 pMac->lim.gLim50Band11dScanDone);
598
599 //Need to disable the timers. If they fire, they will send END_SCAN
600 //while we already send FINISH_SCAN here. This may mess up the gLimHalScanState
601 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
602 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
603 //Set the resume channel to Any valid channel (invalid).
604 //This will instruct HAL to set it to any previous valid channel.
605 peSetResumeChannel(pMac, 0, 0);
606 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
607 //limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
608 }
609 }//(eANI_BOOLEAN_TRUE == fScanning)
610
Kiet Lam623403f2013-10-21 20:29:40 +0530611last:
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 if( eHAL_STATUS_SUCCESS != status )
613 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530614 vos_mem_free( pBssDescr );
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 }
Kiet Lam623403f2013-10-21 20:29:40 +0530616 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700617} /****** end limCheckAndAddBssDescription() ******/
618
619
620
621/**
622 * limScanHashFunction()
623 *
624 *FUNCTION:
625 * This function is called during scan hash entry operations
626 *
627 *LOGIC:
628 *
629 *ASSUMPTIONS:
630 * NA
631 *
632 *NOTE:
633 * NA
634 *
635 * @param bssId - Received BSSid
636 *
637 * @return Hash index
638 */
639
640tANI_U8
641limScanHashFunction(tSirMacAddr bssId)
642{
643 tANI_U16 i, hash = 0;
644
645 for (i = 0; i < sizeof(tSirMacAddr); i++)
646 hash += bssId[i];
647
648 return hash % LIM_MAX_NUM_OF_SCAN_RESULTS;
649} /****** end limScanHashFunction() ******/
650
651
652
653/**
654 * limInitHashTable()
655 *
656 *FUNCTION:
657 * This function is called upon receiving SME_START_REQ
658 * to initialize global cached scan hash table
659 *
660 *LOGIC:
661 *
662 *ASSUMPTIONS:
663 * NA
664 *
665 *NOTE:
666 * NA
667 *
668 * @param pMac - Pointer to Global MAC structure
669 * @return None
670 */
671
672void
673limInitHashTable(tpAniSirGlobal pMac)
674{
675 tANI_U16 i;
676 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
677 pMac->lim.gLimCachedScanHashTable[i] = NULL;
678} /****** end limInitHashTable() ******/
679
680
681
682/**
683 * limLookupNaddHashEntry()
684 *
685 *FUNCTION:
686 * This function is called upon receiving a Beacon or
687 * Probe Response frame during scan phase to store
688 * received BSS description into scan result hash table.
689 *
690 *LOGIC:
691 *
692 *ASSUMPTIONS:
693 * NA
694 *
695 *NOTE:
696 * NA
697 *
698 * @param pMac - Pointer to Global MAC structure
699 * @param pBssDescr - Pointer to BSS description to be
700 * added to the scan result hash table.
701 * @param action - Indicates action to be performed
702 * when same BSS description is found. This is
703 * dependent on whether unique scan result to
704 * be stored or not.
705 *
706 * @return None
707 */
708
709eHalStatus
710limLookupNaddHashEntry(tpAniSirGlobal pMac,
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700711 tLimScanResultNode *pBssDescr, tANI_U8 action,
712 tANI_U8 dontUpdateAll)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713{
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700714 tANI_U8 index, ssidLen = 0;
715 tANI_U8 found = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 tLimScanResultNode *ptemp, *pprev;
717 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
718 int idx, len;
719 tANI_U8 *pbIe;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700720 tANI_S8 rssi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700721
722 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
723 ptemp = pMac->lim.gLimCachedScanHashTable[index];
724
725 //ieFields start with TLV of SSID IE
726 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
727 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
728
729 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
730 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700731 //For infrastructure, check BSSID and SSID. For IBSS, check more
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530733 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
734 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 (tANI_U8 *) ptemp->bssDescription.bssId,
736 sizeof(tSirMacAddr))) && //matching BSSID
Jeff Johnsone7245742012-09-05 17:12:55 -0700737 (pBssDescr->bssDescription.channelId ==
738 ptemp->bssDescription.channelId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530739 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
741 (tANI_U8) (ssidLen + 1)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700742 ((pSirCapTemp->ess) || //we are done for infrastructure
743 //For IBSS, nwType and channelId
744 (((pBssDescr->bssDescription.nwType ==
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 ptemp->bssDescription.nwType) &&
746 (pBssDescr->bssDescription.channelId ==
747 ptemp->bssDescription.channelId))))
748 )
749 {
750 // Found the same BSS description
751 if (action == LIM_HASH_UPDATE)
752 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700753 if(dontUpdateAll)
754 {
755 rssi = ptemp->bssDescription.rssi;
756 }
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
759 {
760 //We get a different, save the old frame WSC IE if it is there
761 idx = 0;
762 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
763 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
764 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
765 //Save WPS IE if it exists
766 pBssDescr->bssDescription.WscIeLen = 0;
767 while(idx < len)
768 {
769 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
770 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) && (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
771 {
772 //Found it
773 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
774 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530775 vos_mem_copy(pBssDescr->bssDescription.WscIeProbeRsp,
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 pbIe, pbIe[1] + 2);
777 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
778 }
779 break;
780 }
781 idx += pbIe[1] + 2;
782 pbIe += pbIe[1] + 2;
783 }
784 }
785
786
787 if(NULL != pMac->lim.gpLimMlmScanReq)
788 {
789 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
790 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
791 &pBssDescr->bssDescription.ieFields + 1))))
792 return eHAL_STATUS_FAILURE;
793 }
794
795 // Delete this entry
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700796 if (ptemp == pMac->lim.gLimCachedScanHashTable[index])
797 pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 else
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700799 pprev->next = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700800
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700801 pMac->lim.gLimMlmScanResultLength -=
802 ptemp->bssDescription.length + sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -0700803
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530804 vos_mem_free(ptemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 }
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700806 found = true;
807 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 }
809 }
810
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700811 //for now, only rssi, we can add more if needed
Madan Mohan Koyyalamudi3e9f2022012-12-04 16:34:19 -0800812 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700813 {
814 pBssDescr->bssDescription.rssi = rssi;
815 }
816
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 // Add this BSS description at same index
818 if (pprev == pMac->lim.gLimCachedScanHashTable[index])
819 {
820 pBssDescr->next = pMac->lim.gLimCachedScanHashTable[index];
821 pMac->lim.gLimCachedScanHashTable[index] = pBssDescr;
822 }
823 else
824 {
825 pBssDescr->next = pprev->next;
826 pprev->next = pBssDescr;
827 }
828 pMac->lim.gLimMlmScanResultLength +=
829 pBssDescr->bssDescription.length + sizeof(tANI_U16);
830
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700831 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 pBssDescr->bssDescription.length,
833 pMac->lim.gLimMlmScanResultLength);
834 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
835
836 // Send new BSS found indication to HDD if CFG option is set
837 if (!found) limSendSmeNeighborBssInd(pMac, pBssDescr);
838
839 //
840 // TODO: IF applicable, do we need to send:
841 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
842 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
843 //
844 return eHAL_STATUS_SUCCESS;
845}
846
847
848
849/**
850 * limDeleteHashEntry()
851 *
852 *FUNCTION:
853 * This function is called upon to delete
854 * a BSS description from scan result hash table.
855 *
856 *LOGIC:
857 *
858 *ASSUMPTIONS:
859 * NA
860 *
861 *NOTE:
862 * Yet to find the utility of the function
863 *
864 * @param pBssDescr - Pointer to BSS description to be
865 * deleted from the scan result hash table.
866 *
867 * @return None
868 */
869
870void limDeleteHashEntry(tLimScanResultNode *pBssDescr)
871{
872} /****** end limDeleteHashEntry() ******/
873
874
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700875#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
876/**
877 * limInitLfrHashTable()
878 *
879 *FUNCTION:
880 * This function is called upon receiving SME_START_REQ
881 * to initialize global cached Lfr scan hash table
882 *
883 *LOGIC:
884 *
885 *ASSUMPTIONS:
886 * NA
887 *
888 *NOTE:
889 * NA
890 *
891 * @param pMac - Pointer to Global MAC structure
892 * @return None
893 */
894
895void
896limInitLfrHashTable(tpAniSirGlobal pMac)
897{
898 tANI_U16 i;
899 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
900 pMac->lim.gLimCachedLfrScanHashTable[i] = NULL;
901} /****** end limInitLfrHashTable() ******/
902
903
904
905/**
906 * limLookupNaddLfrHashEntry()
907 *
908 *FUNCTION:
909 * This function is called upon receiving a Beacon or
910 * Probe Response frame during Lfr scan phase from FW to store
911 * received BSS description into Lfr scan result hash table.
912 *
913 *LOGIC:
914 *
915 *ASSUMPTIONS:
916 * NA
917 *
918 *NOTE:
919 * NA
920 *
921 * @param pMac - Pointer to Global MAC structure
922 * @param pBssDescr - Pointer to BSS description to be
923 * added to the Lfr scan result hash table.
924 * @param action - Indicates action to be performed
925 * when same BSS description is found. This is
926 * dependent on whether unique scan result to
927 * be stored or not.
928 *
929 * @return None
930 */
931
932eHalStatus
933limLookupNaddLfrHashEntry(tpAniSirGlobal pMac,
934 tLimScanResultNode *pBssDescr, tANI_U8 action,
935 tANI_U8 dontUpdateAll)
936{
937 tANI_U8 index, ssidLen = 0;
938 tLimScanResultNode *ptemp, *pprev;
939 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
940 int idx, len;
941 tANI_U8 *pbIe;
942 tANI_S8 rssi = 0;
943
944 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
945 ptemp = pMac->lim.gLimCachedLfrScanHashTable[index];
946
947 //ieFields start with TLV of SSID IE
948 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
949 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
950
951 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
952 {
953 //For infrastructure, check BSSID and SSID. For IBSS, check more
954 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530955 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
956 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700957 (tANI_U8 *) ptemp->bssDescription.bssId,
958 sizeof(tSirMacAddr))) && //matching BSSID
959 (pBssDescr->bssDescription.channelId ==
960 ptemp->bssDescription.channelId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530961 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700962 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
963 (tANI_U8) (ssidLen + 1)) &&
964 ((pSirCapTemp->ess) || //we are done for infrastructure
965 //For IBSS, nwType and channelId
966 (((pBssDescr->bssDescription.nwType ==
967 ptemp->bssDescription.nwType) &&
968 (pBssDescr->bssDescription.channelId ==
969 ptemp->bssDescription.channelId))))
970 )
971 {
972 // Found the same BSS description
973 if (action == LIM_HASH_UPDATE)
974 {
975 if(dontUpdateAll)
976 {
977 rssi = ptemp->bssDescription.rssi;
978 }
979
980 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
981 {
982 //We get a different, save the old frame WSC IE if it is there
983 idx = 0;
984 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
985 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
986 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
987 //Save WPS IE if it exists
988 pBssDescr->bssDescription.WscIeLen = 0;
989 while(idx < len)
990 {
991 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
992 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) &&
993 (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
994 {
995 //Found it
996 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
997 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530998 vos_mem_copy( pBssDescr->bssDescription.WscIeProbeRsp,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700999 pbIe, pbIe[1] + 2);
1000 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
1001 }
1002 break;
1003 }
1004 idx += pbIe[1] + 2;
1005 pbIe += pbIe[1] + 2;
1006 }
1007 }
1008
1009
1010 if(NULL != pMac->lim.gpLimMlmScanReq)
1011 {
1012 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
1013 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
1014 &pBssDescr->bssDescription.ieFields + 1))))
1015 return eHAL_STATUS_FAILURE;
1016 }
1017
1018 // Delete this entry
1019 if (ptemp == pMac->lim.gLimCachedLfrScanHashTable[index])
1020 pprev = pMac->lim.gLimCachedLfrScanHashTable[index] = ptemp->next;
1021 else
1022 pprev->next = ptemp->next;
1023
1024 pMac->lim.gLimMlmLfrScanResultLength -=
1025 ptemp->bssDescription.length + sizeof(tANI_U16);
1026
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301027 vos_mem_free(ptemp);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001028 }
1029 break;
1030 }
1031 }
1032
1033 //for now, only rssi, we can add more if needed
1034 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
1035 {
1036 pBssDescr->bssDescription.rssi = rssi;
1037 }
1038
1039 // Add this BSS description at same index
1040 if (pprev == pMac->lim.gLimCachedLfrScanHashTable[index])
1041 {
1042 pBssDescr->next = pMac->lim.gLimCachedLfrScanHashTable[index];
1043 pMac->lim.gLimCachedLfrScanHashTable[index] = pBssDescr;
1044 }
1045 else
1046 {
1047 pBssDescr->next = pprev->next;
1048 pprev->next = pBssDescr;
1049 }
1050 pMac->lim.gLimMlmLfrScanResultLength +=
1051 pBssDescr->bssDescription.length + sizeof(tANI_U16);
1052
1053 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id\n"),
1054 pBssDescr->bssDescription.length,
1055 pMac->lim.gLimMlmLfrScanResultLength);
1056 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
1057
1058 //
1059 // TODO: IF applicable, do we need to send:
1060 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
1061 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
1062 //
1063 return eHAL_STATUS_SUCCESS;
1064}
1065
1066
1067
1068/**
1069 * limDeleteLfrHashEntry()
1070 *
1071 *FUNCTION:
1072 * This function is called upon to delete
1073 * a BSS description from LFR scan result hash table.
1074 *
1075 *LOGIC:
1076 *
1077 *ASSUMPTIONS:
1078 * NA
1079 *
1080 *NOTE:
1081 * Yet to find the utility of the function
1082 *
1083 * @param pBssDescr - Pointer to BSS description to be
1084 * deleted from the LFR scan result hash table.
1085 *
1086 * @return None
1087 */
1088
1089void limDeleteLfrHashEntry(tLimScanResultNode *pBssDescr)
1090{
1091} /****** end limDeleteLfrHashEntry() ******/
1092
1093#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001094
1095/**
1096 * limCopyScanResult()
1097 *
1098 *FUNCTION:
1099 * This function is called by limProcessSmeMessages() while
1100 * sending SME_SCAN_RSP with scan result to HDD.
1101 *
1102 *LOGIC:
1103 * This function traverses the scan list stored in scan hash table
1104 *
1105 *ASSUMPTIONS:
1106 * NA
1107 *
1108 *NOTE:
1109 * NA
1110 *
1111 * @param pMac - Pointer to Global MAC structure
1112 * @param pDest - Destination pointer
1113 *
1114 * @return None
1115 */
1116
1117void
1118limCopyScanResult(tpAniSirGlobal pMac, tANI_U8 *pDest)
1119{
1120 tLimScanResultNode *ptemp;
1121 tANI_U16 i;
1122 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1123 {
1124 if ((ptemp = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1125 {
1126 while(ptemp)
1127 {
1128 /// Copy entire BSS description including length
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301129 vos_mem_copy( pDest,
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 (tANI_U8 *) &ptemp->bssDescription,
1131 ptemp->bssDescription.length + 2);
1132 pDest += ptemp->bssDescription.length + 2;
1133 ptemp = ptemp->next;
1134 }
1135 }
1136 }
1137} /****** end limCopyScanResult() ******/
1138
1139
1140
1141/**
1142 * limDeleteCachedScanResults()
1143 *
1144 *FUNCTION:
1145 * This function is called by limProcessSmeMessages() upon receiving
1146 * SME_SCAN_REQ with fresh scan result flag set.
1147 *
1148 *LOGIC:
1149 * This function traverses the scan list stored in scan hash table
1150 * and deletes the entries if any
1151 *
1152 *ASSUMPTIONS:
1153 * NA
1154 *
1155 *NOTE:
1156 * NA
1157 *
1158 * @param pMac - Pointer to Global MAC structure
1159 * @return None
1160 */
1161
1162void
1163limDeleteCachedScanResults(tpAniSirGlobal pMac)
1164{
1165 tLimScanResultNode *pNode, *pNextNode;
1166 tANI_U16 i;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301167
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1169 {
1170 if ((pNode = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1171 {
1172 while (pNode)
1173 {
1174 pNextNode = pNode->next;
1175
1176 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301177 vos_mem_free(pNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001178
1179 pNode = pNextNode;
1180 }
1181 }
1182 }
1183
1184 pMac->lim.gLimSmeScanResultLength = 0;
1185} /****** end limDeleteCachedScanResults() ******/
1186
1187
1188
1189/**
1190 * limReInitScanResults()
1191 *
1192 *FUNCTION:
1193 * This function is called delete exisiting scan results
1194 * and initialize the scan hash table
1195 *
1196 *LOGIC:
1197 *
1198 *ASSUMPTIONS:
1199 * NA
1200 *
1201 *NOTE:
1202 * NA
1203 *
1204 * @param pMac - Pointer to Global MAC structure
1205 * @return None
1206 */
1207
1208void
1209limReInitScanResults(tpAniSirGlobal pMac)
1210{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301211 limLog(pMac, LOG1, FL("Re initialize scan hash table."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 limDeleteCachedScanResults(pMac);
1213 limInitHashTable(pMac);
1214
1215 // !!LAC - need to clear out the global scan result length
1216 // since the list was just purged from the hash table.
1217 pMac->lim.gLimMlmScanResultLength = 0;
1218
1219} /****** end limReInitScanResults() ******/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001220#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1221/**
1222 * limDeleteCachedLfrScanResults()
1223 *
1224 *FUNCTION:
1225 * This function is called by limProcessSmeMessages() upon receiving
1226 * SME_SCAN_REQ with flush scan result flag set for LFR.
1227 *
1228 *LOGIC:
1229 * This function traverses the scan list stored in lfr scan hash
1230 * table and deletes the entries if any
1231 *
1232 *ASSUMPTIONS:
1233 * NA
1234 *
1235 *NOTE:
1236 * NA
1237 *
1238 * @param pMac - Pointer to Global MAC structure
1239 * @return None
1240 */
1241
1242void
1243limDeleteCachedLfrScanResults(tpAniSirGlobal pMac)
1244{
1245 tLimScanResultNode *pNode, *pNextNode;
1246 tANI_U16 i;
1247 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1248 {
1249 if ((pNode = pMac->lim.gLimCachedLfrScanHashTable[i]) != NULL)
1250 {
1251 while (pNode)
1252 {
1253 pNextNode = pNode->next;
1254
1255 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301256 vos_mem_free(pNode);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001257
1258 pNode = pNextNode;
1259 }
1260 }
1261 }
1262
1263 pMac->lim.gLimSmeLfrScanResultLength = 0;
1264} /****** end limDeleteCachedLfrScanResults() ******/
1265
1266
1267
1268/**
1269 * limReInitLfrScanResults()
1270 *
1271 *FUNCTION:
1272 * This function is called delete exisiting scan results
1273 * and initialize the lfr scan hash table
1274 *
1275 *LOGIC:
1276 *
1277 *ASSUMPTIONS:
1278 * NA
1279 *
1280 *NOTE:
1281 * NA
1282 *
1283 * @param pMac - Pointer to Global MAC structure
1284 * @return None
1285 */
1286
1287void
1288limReInitLfrScanResults(tpAniSirGlobal pMac)
1289{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301290 limLog(pMac, LOG1, FL("Re initialize lfr scan hash table."));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001291 limDeleteCachedLfrScanResults(pMac);
1292 limInitLfrHashTable(pMac);
1293
1294 // !!LAC - need to clear out the global scan result length
1295 // since the list was just purged from the hash table.
1296 pMac->lim.gLimMlmLfrScanResultLength = 0;
1297
1298} /****** end limReInitLfrScanResults() ******/
1299#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD