blob: 5d1017f47d6a00da412028ff485308d887c69114 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Yeshwanth Sriram Guntukaed0d3d02018-02-23 16:10:46 +05302 * Copyright (c) 2011-2014, 2016-2018 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file limScanResultUtils.cc contains the utility functions
30 * LIM uses for maintaining and accessing scan results on STA.
31 * Author: Chandra Modumudi
32 * Date: 02/13/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 */
37
38#include "limTypes.h"
39#include "limUtils.h"
40#include "limSerDesUtils.h"
41#include "limApi.h"
42#include "limSession.h"
43#if defined WLAN_FEATURE_VOWIFI
44#include "rrmApi.h"
45#endif
Abhishek Singhe3fa11f2014-05-13 11:11:10 +053046#include "vos_utils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48/**
49 * limDeactiveMinChannelTimerDuringScan()
50 *
51 *FUNCTION:
52 * This function is called during scan upon receiving
53 * Beacon/Probe Response frame to deactivate MIN channel
54 * timer if running.
55 *
56 * This function should be called only when pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE
57 *
58 *LOGIC:
59 *
60 *ASSUMPTIONS:
61 * NA
62 *
63 *NOTE:
64 * NA
65 *
66 * @param pMac - Pointer to Global MAC structure
67 *
68 * @return eSIR_SUCCESS in case of success
69 */
70
71tANI_U32
72limDeactivateMinChannelTimerDuringScan(tpAniSirGlobal pMac)
73{
Abhishek Singh01a19762015-09-03 11:07:19 +053074 if ((VOS_TRUE ==
75 tx_timer_running(&pMac->lim.limTimers.gLimMinChannelTimer)) &&
76 (pMac->lim.gLimMlmState == eLIM_MLM_WT_PROBE_RESP_STATE) &&
77 (pMac->lim.gLimHalScanState == eLIM_HAL_SCANNING_STATE))
Jeff Johnson295189b2012-06-20 16:38:30 -070078 {
79 /**
Abhishek Singh01a19762015-09-03 11:07:19 +053080 * Beacon/Probe Response is received during active scanning.
81 * Deactivate MIN channel timer if running.
82 */
Jeff Johnson295189b2012-06-20 16:38:30 -070083 limDeactivateAndChangeTimer(pMac,eLIM_MIN_CHANNEL_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -070084
Jeff Johnson295189b2012-06-20 16:38:30 -070085 }
86 return eSIR_SUCCESS;
87} /*** end limDeactivateMinChannelTimerDuringScan() ***/
88
89
90
91/**
92 * limCollectBssDescription()
93 *
94 *FUNCTION:
95 * This function is called during scan upon receiving
96 * Beacon/Probe Response frame to check if the received
97 * frame matches scan criteria, collect BSS description
98 * and add it to cached scan results.
99 *
100 *LOGIC:
101 *
102 *ASSUMPTIONS:
103 * NA
104 *
105 *NOTE:
106 * NA
107 *
108 * @param pMac - Pointer to Global MAC structure
109 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
110 * @param pRxPacketInfo - Pointer to Received frame's BD
111 * ---------if defined WLAN_FEATURE_VOWIFI------
112 * @param fScanning - flag to indicate if it is during scan.
113 * ---------------------------------------------
114 *
115 * @return None
116 */
117#if defined WLAN_FEATURE_VOWIFI
Ganesh Kondabattini62feb162016-01-14 17:41:05 +0530118void
Jeff Johnson295189b2012-06-20 16:38:30 -0700119limCollectBssDescription(tpAniSirGlobal pMac,
120 tSirBssDescription *pBssDescr,
121 tpSirProbeRespBeacon pBPR,
122 tANI_U8 *pRxPacketInfo,
123 tANI_U8 fScanning)
124#else
Ganesh Kondabattini62feb162016-01-14 17:41:05 +0530125void
Jeff Johnson295189b2012-06-20 16:38:30 -0700126limCollectBssDescription(tpAniSirGlobal pMac,
127 tSirBssDescription *pBssDescr,
128 tpSirProbeRespBeacon pBPR,
129 tANI_U8 *pRxPacketInfo)
130#endif
131{
132 tANI_U8 *pBody;
133 tANI_U32 ieLen = 0;
134 tpSirMacMgmtHdr pHdr;
135 tANI_U8 channelNum;
136 tANI_U8 rxChannel;
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700137 tANI_U8 rfBand = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700138
139 pHdr = WDA_GET_RX_MAC_HEADER(pRxPacketInfo);
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800140 VOS_ASSERT(WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) >= SIR_MAC_B_PR_SSID_OFFSET);
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) - SIR_MAC_B_PR_SSID_OFFSET;
142 rxChannel = WDA_GET_RX_CH(pRxPacketInfo);
143 pBody = WDA_GET_RX_MPDU_DATA(pRxPacketInfo);
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700144 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700145
146
147 /**
148 * Length of BSS desription is without length of
149 * length itself and length of pointer
kjlie157ed02016-07-29 11:16:09 +0800150 * that holds ieFields
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 */
152 pBssDescr->length = (tANI_U16)(
kjlie157ed02016-07-29 11:16:09 +0800153 ((uintptr_t)OFFSET_OF(tSirBssDescription, ieFields)) -
154 sizeof(pBssDescr->length) + ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700155
156 // Copy BSS Id
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530157 vos_mem_copy((tANI_U8 *) &pBssDescr->bssId,
158 (tANI_U8 *) pHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 sizeof(tSirMacAddr));
160
161 // Copy Timestamp, Beacon Interval and Capability Info
162 pBssDescr->scanSysTimeMsec = vos_timer_get_system_time();
163
164 pBssDescr->timeStamp[0] = pBPR->timeStamp[0];
165 pBssDescr->timeStamp[1] = pBPR->timeStamp[1];
166 pBssDescr->beaconInterval = pBPR->beaconInterval;
167 pBssDescr->capabilityInfo = limGetU16((tANI_U8 *) &pBPR->capabilityInfo);
168
Kapil Gupta04ab1992016-06-26 13:36:51 +0530169 pBssDescr->HTCapsPresent = 0;
170 pBssDescr->chanWidth = eHT_CHANNEL_WIDTH_20MHZ;
171 pBssDescr->wmeInfoPresent = 0;
172 pBssDescr->vhtCapsPresent = 0;
173 pBssDescr->beacomformingCapable = 0;
174 /* HT capability */
175 if (pBPR->HTCaps.present) {
176 pBssDescr->HTCapsPresent = 1;
177 if (pBPR->HTCaps.supportedChannelWidthSet)
178 pBssDescr->chanWidth = eHT_CHANNEL_WIDTH_40MHZ;
179 }
180 if (pBPR->wmeEdcaPresent)
181 pBssDescr->wmeInfoPresent = 1;
182
183#ifdef WLAN_FEATURE_11AC
184 /* VHT Parameters */
185 if (pBPR->VHTCaps.present) {
186 pBssDescr->vhtCapsPresent = 1;
187 if (pBPR->VHTCaps.muBeamformerCap)
188 pBssDescr->beacomformingCapable = 1;
189 }
190 if (pBPR->VHTOperation.present)
191 if (pBPR->VHTOperation.chanWidth == 1)
192 pBssDescr->chanWidth = eHT_CHANNEL_WIDTH_80MHZ;
193#endif
194 if(!pBssDescr->beaconInterval )
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +0530195 {
196 limLog(pMac, LOGW,
197 FL("Beacon Interval is ZERO, making it to default 100 "
198 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pHdr->bssId));
199 pBssDescr->beaconInterval= 100;
200 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 /*
202 * There is a narrow window after Channel Switch msg is sent to HAL and before the AGC is shut
203 * down and beacons/Probe Rsps can trickle in and we may report the incorrect channel in 5Ghz
204 * band, so not relying on the 'last Scanned Channel' stored in LIM.
205 * Instead use the value returned by RXP in BD. This the the same value which HAL programs into
206 * RXP before every channel switch.
207 * Right now there is a problem in 5Ghz, where we are receiving beacons from a channel different from
208 * the currently scanned channel. so incorrect channel is reported to CSR and association does not happen.
209 * So for now we keep on looking for the channel info in the beacon (DSParamSet IE OR HT Info IE), and only if it
210 * is not present in the beacon, we go for the channel info present in RXP.
211 * 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.
212 * So The problem of incorrect channel reporting in 5Ghz will still remain for 11a devices.
213 */
214 pBssDescr->channelId = limGetChannelFromBeacon(pMac, pBPR);
215
216 if (pBssDescr->channelId == 0)
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700217 {
218 /* If the channel Id is not retrieved from Beacon, extract the channel from BD */
219 /* Unmapped the channel.This We have to do since we have done mapping in the hal to
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 overcome the limitation of RXBD of not able to accomodate the bigger channel number.*/
Kiran Kumar Lokere79540f92013-04-25 17:32:16 -0700221 if ((!rfBand) || IS_5G_BAND(rfBand))
222 {
223 rxChannel = limUnmapChannel(rxChannel);
224 }
225 if (!rxChannel)
226 {
227 rxChannel = pMac->lim.gLimCurrentScanChannelId;
228 }
229 pBssDescr->channelId = rxChannel;
230 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700231
Gopichand Nakkalad492d202013-05-10 02:50:47 +0530232 pBssDescr->channelIdSelf = pBssDescr->channelId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 //set the network type in bss description
234 channelNum = pBssDescr->channelId;
235 pBssDescr->nwType = limGetNwType(pMac, channelNum, SIR_MAC_MGMT_FRAME, pBPR);
236
237 pBssDescr->aniIndicator = pBPR->propIEinfo.aniIndicator;
238
239 // Copy RSSI & SINR from BD
240
241 PELOG4(limLog(pMac, LOG4, "***********BSS Description for BSSID:*********** ");
242 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG4, pBssDescr->bssId, 6 );
243 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG4, (tANI_U8*)pRxPacketInfo, 36 );)
244
245 pBssDescr->rssi = (tANI_S8)WDA_GET_RX_RSSI_DB(pRxPacketInfo);
246
247 //SINR no longer reported by HW
248 pBssDescr->sinr = 0;
249
Deepthi Gowri2f435132016-05-18 19:30:17 +0530250 pBssDescr->nReceivedTime = vos_timer_get_system_time();
Jeff Johnson295189b2012-06-20 16:38:30 -0700251
252#if defined WLAN_FEATURE_VOWIFI
253 if( fScanning )
254 {
255 rrmGetStartTSF( pMac, pBssDescr->startTSF );
256 pBssDescr->parentTSF = WDA_GET_RX_TIMESTAMP(pRxPacketInfo);
257 }
258#endif
259
260#ifdef WLAN_FEATURE_VOWIFI_11R
261 // MobilityDomain
262 pBssDescr->mdie[0] = 0;
263 pBssDescr->mdie[1] = 0;
264 pBssDescr->mdie[2] = 0;
265 pBssDescr->mdiePresent = FALSE;
266 // If mdie is present in the probe resp we
267 // fill it in the bss description
268 if( pBPR->mdiePresent)
269 {
270 pBssDescr->mdiePresent = TRUE;
271 pBssDescr->mdie[0] = pBPR->mdie[0];
272 pBssDescr->mdie[1] = pBPR->mdie[1];
273 pBssDescr->mdie[2] = pBPR->mdie[2];
274 }
275#endif
276
Kapil Gupta04ab1992016-06-26 13:36:51 +0530277#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_ROAM_SCAN_OFFLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 pBssDescr->QBSSLoad_present = FALSE;
279 pBssDescr->QBSSLoad_avail = 0;
280 if( pBPR->QBSSLoad.present)
281 {
282 pBssDescr->QBSSLoad_present = TRUE;
283 pBssDescr->QBSSLoad_avail = pBPR->QBSSLoad.avail;
Kapil Gupta04ab1992016-06-26 13:36:51 +0530284 pBssDescr->QBSS_ChanLoad = pBPR->QBSSLoad.chautil;
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 }
286#endif
287 // Copy IE fields
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530288 vos_mem_copy((tANI_U8 *) &pBssDescr->ieFields,
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 pBody + SIR_MAC_B_PR_SSID_OFFSET,
290 ieLen);
291
292 //sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOGW, (tANI_U8 *) pBssDescr, pBssDescr->length + 2 );
293 limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700294 FL("Collected BSS Description for Channel(%1d), length(%u), aniIndicator(%d), IE Fields(%u)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 pBssDescr->channelId,
296 pBssDescr->length,
297 pBssDescr->aniIndicator,
298 ieLen );
299
Ganesh Kondabattini62feb162016-01-14 17:41:05 +0530300 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700301} /*** end limCollectBssDescription() ***/
302
303/**
304 * limIsScanRequestedSSID()
305 *
306 *FUNCTION:
307 * This function is called during scan upon receiving
308 * Beacon/Probe Response frame to check if the received
309 * SSID is present in the list of requested SSIDs in scan
310 *
311 *LOGIC:
312 *
313 *ASSUMPTIONS:
314 * NA
315 *
316 *NOTE:
317 * NA
318 *
319 * @param pMac - Pointer to Global MAC structure
320 * @param ssId - SSID Received in beacons/Probe responses that is compared against the
321 requeusted SSID in scan list
322 * ---------------------------------------------
323 *
324 * @return boolean - TRUE if SSID is present in requested list, FALSE otherwise
325 */
326
327tANI_BOOLEAN limIsScanRequestedSSID(tpAniSirGlobal pMac, tSirMacSSid *ssId)
328{
329 tANI_U8 i = 0;
330
331 for (i = 0; i < pMac->lim.gpLimMlmScanReq->numSsid; i++)
332 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530333 if ( eANI_BOOLEAN_TRUE == vos_mem_compare((tANI_U8 *) ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 (tANI_U8 *) &pMac->lim.gpLimMlmScanReq->ssId[i],
335 (tANI_U8) (pMac->lim.gpLimMlmScanReq->ssId[i].length + 1)))
336 {
337 return eANI_BOOLEAN_TRUE;
338 }
339 }
340 return eANI_BOOLEAN_FALSE;
341}
342
343/**
344 * limCheckAndAddBssDescription()
345 *
346 *FUNCTION:
347 * This function is called during scan upon receiving
348 * Beacon/Probe Response frame to check if the received
349 * frame matches scan criteria, collect BSS description
350 * and add it to cached scan results.
351 *
352 *LOGIC:
353 *
354 *ASSUMPTIONS:
355 * NA
356 *
357 *NOTE:
358 * NA
359 *
360 * @param pMac - Pointer to Global MAC structure
361 * @param pBPR - Pointer to parsed Beacon/Probe Response structure
362 * @param pRxPacketInfo - Pointer to Received frame's BD
363 * @param fScanning - boolean to indicate whether the BSS is from current scan or just happen to receive a beacon
364 *
365 * @return None
366 */
367
368void
369limCheckAndAddBssDescription(tpAniSirGlobal pMac,
370 tpSirProbeRespBeacon pBPR,
371 tANI_U8 *pRxPacketInfo,
372 tANI_BOOLEAN fScanning,
373 tANI_U8 fProbeRsp)
374{
375 tLimScanResultNode *pBssDescr;
376 tANI_U32 frameLen, ieLen = 0;
377 tANI_U8 rxChannelInBeacon = 0;
378 eHalStatus status;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700379 tANI_U8 dontUpdateAll = 0;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700380 tANI_U8 rfBand = 0;
381 tANI_U8 rxChannelInBD = 0;
Abhishek Singh56c29812018-06-12 14:07:52 +0530382 bool chan_info_present = true;
Jeff Johnson295189b2012-06-20 16:38:30 -0700383
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 tSirMacAddr bssid = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
Agrawal Ashish9948e082014-07-17 13:48:37 +0530385 tSirMacAddr bssid_zero = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 tANI_BOOLEAN fFound = FALSE;
387 tpSirMacDataHdr3a pHdr;
388
389 pHdr = WDA_GET_RX_MPDUHEADER3A((tANI_U8 *)pRxPacketInfo);
390
Agrawal Ashish9948e082014-07-17 13:48:37 +0530391 // Check For Null BSSID; Skip in case of P2P.
392 if (vos_mem_compare(bssid_zero, &pHdr->addr3, 6))
393 {
394 return ;
395 }
396
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 //Checking if scanning for a particular BSSID
398 if ((fScanning) && (pMac->lim.gpLimMlmScanReq))
399 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530400 fFound = vos_mem_compare(pHdr->addr3, &pMac->lim.gpLimMlmScanReq->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 if (!fFound)
402 {
403 if ((pMac->lim.gpLimMlmScanReq->p2pSearch) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530404 (vos_mem_compare(pBPR->P2PProbeRes.P2PDeviceInfo.P2PDeviceAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 &pMac->lim.gpLimMlmScanReq->bssId, 6)))
406 {
407 fFound = eANI_BOOLEAN_TRUE;
408 }
409 }
410 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700411
412 /**
413 * Compare SSID with the one sent in
414 * Probe Request frame, if any.
415 * If they don't match, ignore the
416 * Beacon frame.
417 * pMac->lim.gLimMlmScanReq->ssId.length == 0
418 * indicates Broadcast SSID.
419 * When gLimReturnAfterFirstMatch is set, it means the scan has to match
420 * a SSID (if it is also set). Ignore the other BSS in that case.
421 */
422
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700423#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
424 if (!(WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo)))
425 {
426#endif
427 if ((pMac->lim.gpLimMlmScanReq) &&
428 (((fScanning) &&
429 ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) &&
430 (pMac->lim.gpLimMlmScanReq->numSsid) &&
431 !limIsScanRequestedSSID(pMac, &pBPR->ssId)) ||
432 (!fFound && (pMac->lim.gpLimMlmScanReq &&
433 pMac->lim.gpLimMlmScanReq->bssId) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530434 !vos_mem_compare(bssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700435 &pMac->lim.gpLimMlmScanReq->bssId, 6))))
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 {
437 /**
438 * Received SSID does not match with
439 * the one we're scanning for.
440 * Ignore received Beacon frame
441 */
442
443 return;
444 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700445#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
446 }
447#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700448
449 /* There is no point in caching & reporting the scan results for APs
450 * which are in the process of switching the channel. So, we are not
451 * caching the scan results for APs which are adverzing the channel-switch
452 * element in their beacons and probe responses.
453 */
Wu Gaoc3bfe0a2018-03-26 13:11:28 +0800454 if(pBPR->channelSwitchPresent)
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 {
Yeshwanth Sriram Guntuka3ad15d52018-04-16 14:34:25 +0530456 if (pBPR->ext_chan_switch_ann.new_channel !=
457 limGetChannelFromBeacon(pMac, pBPR))
458 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 }
460
Wu Gaoc3bfe0a2018-03-26 13:11:28 +0800461 if(pBPR->ecsa_present) {
462 limLog(pMac, LOGW, FL("ECSA IE present"));
463 /* Still add to scan result if ECSA IE present and new channel
464 * equal to current channel.
465 */
466 if (pBPR->channelNumber!= HAL_INVALID_CHANNEL_ID &&
467 pBPR->ext_chan_switch_ann.new_channel != HAL_INVALID_CHANNEL_ID &&
468 pBPR->channelNumber != pBPR->ext_chan_switch_ann.new_channel) {
469 limLog(pMac, LOGW, FL("ignore this AP"));
470 return;
471 }
472
473 }
474
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 /* If beacon/probe resp DS param channel does not match with
476 * RX BD channel then don't save the results. It might be a beacon
477 * from another channel heard as noise on the current scanning channel
478 */
479
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700480 if ((pBPR->dsParamsPresent) || (pBPR->HTInfo.present))
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 {
482 /* This means that we are in 2.4GHz mode or 5GHz 11n mode */
483 rxChannelInBeacon = limGetChannelFromBeacon(pMac, pBPR);
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700484 rfBand = WDA_GET_RX_RFBAND(pRxPacketInfo);
485 rxChannelInBD = WDA_GET_RX_CH(pRxPacketInfo);
486
487 if ((!rfBand) || IS_5G_BAND(rfBand))
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 {
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700489 rxChannelInBD = limUnmapChannel(rxChannelInBD);
490 }
491
492 if(rxChannelInBD != rxChannelInBeacon)
493 {
494 /* BCAST Frame, if CH do not match, Drop */
495 if(WDA_IS_RX_BCAST(pRxPacketInfo))
496 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700497 limLog(pMac, LOG3, FL("Beacon/Probe Rsp dropped. Channel in BD %d. "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700498 "Channel in beacon" " %d"),
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700499 WDA_GET_RX_CH(pRxPacketInfo),limGetChannelFromBeacon(pMac, pBPR));
500 return;
Leela Venkata Kiran Kumar Reddy Chiralacdd13002013-10-16 15:43:47 -0700501 }
502 /* Unit cast frame, Probe RSP, do not drop */
503 else
504 {
505 dontUpdateAll = 1;
506 limLog(pMac, LOG3, FL("SSID %s, CH in ProbeRsp %d, CH in BD %d, miss-match, Do Not Drop"),
507 pBPR->ssId.ssId,
508 rxChannelInBeacon,
509 WDA_GET_RX_CH(pRxPacketInfo));
510 WDA_GET_RX_CH(pRxPacketInfo) = rxChannelInBeacon;
511 }
512 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 }
Abhishek Singh56c29812018-06-12 14:07:52 +0530514 else
515 {
516 chan_info_present = false;
517 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700518
519 /**
520 * Allocate buffer to hold BSS description from
521 * received Beacon frame.
522 * Include size of fixed fields and IEs length
523 */
524
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800525 ieLen = WDA_GET_RX_PAYLOAD_LEN(pRxPacketInfo);
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530526 if (ieLen <= (SIR_MAC_B_PR_SSID_OFFSET + 2))
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800527 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700528 limLog(pMac, LOGP,
529 FL("RX packet has invalid length %d"), ieLen);
530 return;
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -0800531 }
532
533 ieLen -= SIR_MAC_B_PR_SSID_OFFSET;
534
535 frameLen = sizeof(tLimScanResultNode) + ieLen - sizeof(tANI_U32); //Sizeof(tANI_U32) is for ieFields[1]
Jeff Johnson295189b2012-06-20 16:38:30 -0700536
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530537 pBssDescr = vos_mem_malloc(frameLen);
538 if ( NULL == pBssDescr )
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 {
540 // Log error
541 limLog(pMac, LOGP,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530542 FL("call for AllocateMemory failed for storing BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700543
544 return;
545 }
546
Padma, Santhosh Kumarf21a0d92015-11-02 12:41:06 +0530547 vos_mem_zero(pBssDescr, frameLen);
548
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 // In scan state, store scan result.
550#if defined WLAN_FEATURE_VOWIFI
Ganesh Kondabattini62feb162016-01-14 17:41:05 +0530551 limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 pBPR, pRxPacketInfo, fScanning);
553#else
Ganesh Kondabattini62feb162016-01-14 17:41:05 +0530554 limCollectBssDescription(pMac, &pBssDescr->bssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -0700555 pBPR, pRxPacketInfo);
556#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 pBssDescr->bssDescription.fProbeRsp = fProbeRsp;
558
559 pBssDescr->next = NULL;
560
561 /**
562 * Depending on whether to store unique or all
563 * scan results, pass hash update/add parameter
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700564 * For LFR candidates just add them on it's own cache
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 */
566
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700567#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
568 if (WDA_GET_OFFLOADSCANLEARN(pRxPacketInfo))
569 {
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530570 limLog(pMac, LOG1, FL(" pHdr->addr1:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800571 MAC_ADDR_ARRAY(pHdr->addr1));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530572 limLog(pMac, LOG1, FL(" pHdr->addr2:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800573 MAC_ADDR_ARRAY(pHdr->addr2));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530574 limLog(pMac, LOG1, FL(" pHdr->addr3:"MAC_ADDRESS_STR),
Arif Hussain24bafea2013-11-15 15:10:03 -0800575 MAC_ADDR_ARRAY(pHdr->addr3));
Padma, Santhosh Kumar30971cf2015-04-06 19:59:37 +0530576 limLog( pMac, LOG1, FL("Save this entry in LFR cache"));
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530577 status = limLookupNaddLfrHashEntry(pMac, pBssDescr, LIM_HASH_ADD,
578 dontUpdateAll, ieLen - 2);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700579 }
580 else
581#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 //If it is not scanning, only save unique results
583 if (pMac->lim.gLimReturnUniqueResults || (!fScanning))
584 {
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530585 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_UPDATE,
Abhishek Singh56c29812018-06-12 14:07:52 +0530586 dontUpdateAll, ieLen - 2,
587 chan_info_present);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 }
589 else
590 {
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530591 status = limLookupNaddHashEntry(pMac, pBssDescr, LIM_HASH_ADD,
Abhishek Singh56c29812018-06-12 14:07:52 +0530592 dontUpdateAll, ieLen - 2,
593 chan_info_present);
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 }
595
596 if(fScanning)
597 {
598 if ((pBssDescr->bssDescription.channelId <= 14) &&
599 (pMac->lim.gLimReturnAfterFirstMatch & 0x40) &&
600 pBPR->countryInfoPresent)
601 pMac->lim.gLim24Band11dScanDone = 1;
602
603 if ((pBssDescr->bssDescription.channelId > 14) &&
604 (pMac->lim.gLimReturnAfterFirstMatch & 0x80) &&
605 pBPR->countryInfoPresent)
606 pMac->lim.gLim50Band11dScanDone = 1;
607
608 if ( ( pMac->lim.gLimReturnAfterFirstMatch & 0x01 ) ||
609 ( pMac->lim.gLim24Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x40 ) ) ||
Gopichand Nakkala48b4d7e2013-03-06 23:34:16 +0530610 ( pMac->lim.gLim50Band11dScanDone && ( pMac->lim.gLimReturnAfterFirstMatch & 0x80 ) ) ||
611 fFound )
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 {
613 /**
614 * Stop scanning and return the BSS description(s)
615 * collected so far.
616 */
617 limLog(pMac,
618 LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700619 FL("Completed scan: 24Band11dScan = %d, 50Band11dScan = %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 pMac->lim.gLim24Band11dScanDone,
621 pMac->lim.gLim50Band11dScanDone);
622
623 //Need to disable the timers. If they fire, they will send END_SCAN
624 //while we already send FINISH_SCAN here. This may mess up the gLimHalScanState
625 limDeactivateAndChangeTimer(pMac, eLIM_MIN_CHANNEL_TIMER);
626 limDeactivateAndChangeTimer(pMac, eLIM_MAX_CHANNEL_TIMER);
627 //Set the resume channel to Any valid channel (invalid).
628 //This will instruct HAL to set it to any previous valid channel.
629 peSetResumeChannel(pMac, 0, 0);
630 limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
631 //limSendHalFinishScanReq( pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE );
632 }
633 }//(eANI_BOOLEAN_TRUE == fScanning)
634
635 if( eHAL_STATUS_SUCCESS != status )
636 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530637 vos_mem_free( pBssDescr );
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 }
639} /****** end limCheckAndAddBssDescription() ******/
640
641
642
643/**
644 * limScanHashFunction()
645 *
646 *FUNCTION:
647 * This function is called during scan hash entry operations
648 *
649 *LOGIC:
650 *
651 *ASSUMPTIONS:
652 * NA
653 *
654 *NOTE:
655 * NA
656 *
657 * @param bssId - Received BSSid
658 *
659 * @return Hash index
660 */
661
662tANI_U8
663limScanHashFunction(tSirMacAddr bssId)
664{
665 tANI_U16 i, hash = 0;
666
667 for (i = 0; i < sizeof(tSirMacAddr); i++)
668 hash += bssId[i];
669
670 return hash % LIM_MAX_NUM_OF_SCAN_RESULTS;
671} /****** end limScanHashFunction() ******/
672
673
674
675/**
676 * limInitHashTable()
677 *
678 *FUNCTION:
679 * This function is called upon receiving SME_START_REQ
680 * to initialize global cached scan 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 * @return None
692 */
693
694void
695limInitHashTable(tpAniSirGlobal pMac)
696{
697 tANI_U16 i;
698 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
699 pMac->lim.gLimCachedScanHashTable[i] = NULL;
700} /****** end limInitHashTable() ******/
701
Jeff Johnson295189b2012-06-20 16:38:30 -0700702eHalStatus
703limLookupNaddHashEntry(tpAniSirGlobal pMac,
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700704 tLimScanResultNode *pBssDescr, tANI_U8 action,
Abhishek Singh56c29812018-06-12 14:07:52 +0530705 tANI_U8 dontUpdateAll, tANI_U32 ie_len,
706 bool chan_info_present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700707{
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700708 tANI_U8 index, ssidLen = 0;
709 tANI_U8 found = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 tLimScanResultNode *ptemp, *pprev;
711 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530712 int len, elem_id, elem_len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 tANI_U8 *pbIe;
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700714 tANI_S8 rssi = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700715
716 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
717 ptemp = pMac->lim.gLimCachedScanHashTable[index];
718
719 //ieFields start with TLV of SSID IE
720 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530721 if ((ssidLen > ie_len) || (ssidLen > DOT11F_IE_SSID_MAX_LEN)) {
722 limLog(pMac, LOGE, FL("SSID length %d, IE overall Length %d"),
723 ssidLen, ie_len);
724 return eHAL_STATUS_FAILURE;
725 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
727
728 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
729 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700730 //For infrastructure, check BSSID and SSID. For IBSS, check more
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530732 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
733 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 (tANI_U8 *) ptemp->bssDescription.bssId,
735 sizeof(tSirMacAddr))) && //matching BSSID
Abhishek Singhe3fa11f2014-05-13 11:11:10 +0530736 // matching band to update new channel info
737 (vos_chan_to_band(pBssDescr->bssDescription.channelId) ==
738 vos_chan_to_band(ptemp->bssDescription.channelId)) &&
Abhinav Kumar2d590282018-06-28 11:45:15 +0530739 (*((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1) ==
740 *((tANI_U8 *) &ptemp->bssDescription.ieFields + 1)) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530741 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
743 (tANI_U8) (ssidLen + 1)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700744 ((pSirCapTemp->ess) || //we are done for infrastructure
745 //For IBSS, nwType and channelId
746 (((pBssDescr->bssDescription.nwType ==
Jeff Johnson295189b2012-06-20 16:38:30 -0700747 ptemp->bssDescription.nwType) &&
748 (pBssDescr->bssDescription.channelId ==
749 ptemp->bssDescription.channelId))))
750 )
751 {
752 // Found the same BSS description
753 if (action == LIM_HASH_UPDATE)
754 {
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700755 if(dontUpdateAll)
756 {
757 rssi = ptemp->bssDescription.rssi;
758 }
759
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530760 if(pBssDescr->bssDescription.fProbeRsp !=
761 ptemp->bssDescription.fProbeRsp)
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 {
763 //We get a different, save the old frame WSC IE if it is there
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530764 len = ptemp->bssDescription.length -
765 sizeof(tSirBssDescription) +
766 sizeof(tANI_U16) + sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
768 //Save WPS IE if it exists
769 pBssDescr->bssDescription.WscIeLen = 0;
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530770 while (len >= 2)
Jeff Johnson295189b2012-06-20 16:38:30 -0700771 {
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530772 elem_id = pbIe[0];
773 elem_len = pbIe[1];
774 len -= 2;
775 if (elem_len > len) {
776 limLog(pMac, LOGW, FL("Invalid eid: %d elem_len: %d left: %d"),
777 elem_id, elem_len, len);
778 return eHAL_STATUS_FAILURE;
779 }
780 if ((elem_id == DOT11F_EID_WSCPROBERES) &&
781 (elem_len >= DOT11F_IE_WSCPROBERES_MIN_LEN) &&
782 ((pbIe[2] == 0x00) && (pbIe[3] == 0x50) &&
783 (pbIe[4] == 0xf2) &&
784 (pbIe[5] == 0x04)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 {
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530786 if((elem_len + 2) <= WSCIE_PROBE_RSP_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 {
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530788 vos_mem_copy(
789 pBssDescr->bssDescription.WscIeProbeRsp,
790 pbIe, elem_len + 2);
791 pBssDescr->bssDescription.WscIeLen =
792 elem_len + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 }
794 break;
795 }
Abhishek Singh02b08ed2018-09-26 15:04:58 +0530796 len -= elem_len;
797 pbIe += (elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 }
799 }
Abhishek Singh56c29812018-06-12 14:07:52 +0530800 /*
801 * Due to Rx sensitivity issue, sometime beacons are seen on
802 * adjacent channel so workaround in software is needed. If DS
803 * params or HT info are present driver can get proper channel
804 * info from these IEs and the older RSSI values are used in new
805 * entry.
806 *
807 * For the cases where DS params and HT info is not present,
808 * driver needs to check below conditions to update proper
809 * channel so that the older RSSI and channel values are used in
810 * new entry:
811 * -- The old entry channel and new entry channel are not same
812 * -- RSSI is below 15db or more from old value, this indicate
813 * that the signal has leaked in adjacent channel
814 */
815 if (!pBssDescr->bssDescription.fProbeRsp &&
816 !chan_info_present &&
817 (pBssDescr->bssDescription.channelId !=
818 ptemp->bssDescription.channelId) &&
819 ((ptemp->bssDescription.rssi -
820 pBssDescr->bssDescription.rssi) >
821 SIR_ADJACENT_CHANNEL_RSSI_DIFF_THRESHOLD)) {
822 pBssDescr->bssDescription.channelId =
823 ptemp->bssDescription.channelId;
824 pBssDescr->bssDescription.rssi =
825 ptemp->bssDescription.rssi;
826 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700827
828
829 if(NULL != pMac->lim.gpLimMlmScanReq)
830 {
831 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
832 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
833 &pBssDescr->bssDescription.ieFields + 1))))
834 return eHAL_STATUS_FAILURE;
835 }
836
837 // Delete this entry
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700838 if (ptemp == pMac->lim.gLimCachedScanHashTable[index])
839 pprev = pMac->lim.gLimCachedScanHashTable[index] = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 else
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700841 pprev->next = ptemp->next;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700843 pMac->lim.gLimMlmScanResultLength -=
844 ptemp->bssDescription.length + sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -0700845
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530846 vos_mem_free(ptemp);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 }
Madan Mohan Koyyalamudica43cdf2012-09-24 13:15:49 -0700848 found = true;
849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 }
851 }
852
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700853 //for now, only rssi, we can add more if needed
Madan Mohan Koyyalamudi3e9f2022012-12-04 16:34:19 -0800854 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
Madan Mohan Koyyalamudi15865592012-09-28 15:55:37 -0700855 {
856 pBssDescr->bssDescription.rssi = rssi;
857 }
858
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 // Add this BSS description at same index
860 if (pprev == pMac->lim.gLimCachedScanHashTable[index])
861 {
862 pBssDescr->next = pMac->lim.gLimCachedScanHashTable[index];
863 pMac->lim.gLimCachedScanHashTable[index] = pBssDescr;
864 }
865 else
866 {
867 pBssDescr->next = pprev->next;
868 pprev->next = pBssDescr;
869 }
870 pMac->lim.gLimMlmScanResultLength +=
871 pBssDescr->bssDescription.length + sizeof(tANI_U16);
872
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700873 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 pBssDescr->bssDescription.length,
875 pMac->lim.gLimMlmScanResultLength);
876 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
877
878 // Send new BSS found indication to HDD if CFG option is set
879 if (!found) limSendSmeNeighborBssInd(pMac, pBssDescr);
880
881 //
882 // TODO: IF applicable, do we need to send:
883 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
884 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
885 //
886 return eHAL_STATUS_SUCCESS;
887}
888
889
890
891/**
892 * limDeleteHashEntry()
893 *
894 *FUNCTION:
895 * This function is called upon to delete
896 * a BSS description from scan result hash table.
897 *
898 *LOGIC:
899 *
900 *ASSUMPTIONS:
901 * NA
902 *
903 *NOTE:
904 * Yet to find the utility of the function
905 *
906 * @param pBssDescr - Pointer to BSS description to be
907 * deleted from the scan result hash table.
908 *
909 * @return None
910 */
911
912void limDeleteHashEntry(tLimScanResultNode *pBssDescr)
913{
914} /****** end limDeleteHashEntry() ******/
915
916
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700917#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
918/**
919 * limInitLfrHashTable()
920 *
921 *FUNCTION:
922 * This function is called upon receiving SME_START_REQ
923 * to initialize global cached Lfr scan hash table
924 *
925 *LOGIC:
926 *
927 *ASSUMPTIONS:
928 * NA
929 *
930 *NOTE:
931 * NA
932 *
933 * @param pMac - Pointer to Global MAC structure
934 * @return None
935 */
936
937void
938limInitLfrHashTable(tpAniSirGlobal pMac)
939{
940 tANI_U16 i;
941 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
942 pMac->lim.gLimCachedLfrScanHashTable[i] = NULL;
943} /****** end limInitLfrHashTable() ******/
944
945
946
947/**
948 * limLookupNaddLfrHashEntry()
949 *
950 *FUNCTION:
951 * This function is called upon receiving a Beacon or
952 * Probe Response frame during Lfr scan phase from FW to store
953 * received BSS description into Lfr scan result hash table.
954 *
955 *LOGIC:
956 *
957 *ASSUMPTIONS:
958 * NA
959 *
960 *NOTE:
961 * NA
962 *
963 * @param pMac - Pointer to Global MAC structure
964 * @param pBssDescr - Pointer to BSS description to be
965 * added to the Lfr scan result hash table.
966 * @param action - Indicates action to be performed
967 * when same BSS description is found. This is
968 * dependent on whether unique scan result to
969 * be stored or not.
970 *
971 * @return None
972 */
973
974eHalStatus
975limLookupNaddLfrHashEntry(tpAniSirGlobal pMac,
976 tLimScanResultNode *pBssDescr, tANI_U8 action,
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530977 tANI_U8 dontUpdateAll, tANI_U32 ie_len)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700978{
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530979 tANI_U8 index, ssidLen = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700980 tLimScanResultNode *ptemp, *pprev;
981 tSirMacCapabilityInfo *pSirCap, *pSirCapTemp;
982 int idx, len;
983 tANI_U8 *pbIe;
984 tANI_S8 rssi = 0;
985
986 index = limScanHashFunction(pBssDescr->bssDescription.bssId);
987 ptemp = pMac->lim.gLimCachedLfrScanHashTable[index];
988
989 //ieFields start with TLV of SSID IE
990 ssidLen = * ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1);
Abhinav Kumarb2347d42018-06-13 12:44:14 +0530991 if ((ssidLen > ie_len) || (ssidLen > DOT11F_IE_SSID_MAX_LEN)) {
992 limLog(pMac, LOGE, FL("SSID length %d, IE overall Length %d"),
993 ssidLen, ie_len);
994 return eHAL_STATUS_FAILURE;
995 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700996 pSirCap = (tSirMacCapabilityInfo *)&pBssDescr->bssDescription.capabilityInfo;
997
998 for (pprev = ptemp; ptemp; pprev = ptemp, ptemp = ptemp->next)
999 {
1000 //For infrastructure, check BSSID and SSID. For IBSS, check more
1001 pSirCapTemp = (tSirMacCapabilityInfo *)&ptemp->bssDescription.capabilityInfo;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301002 if ((pSirCapTemp->ess == pSirCap->ess) && //matching ESS type first
1003 (vos_mem_compare( (tANI_U8 *) pBssDescr->bssDescription.bssId,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001004 (tANI_U8 *) ptemp->bssDescription.bssId,
1005 sizeof(tSirMacAddr))) && //matching BSSID
1006 (pBssDescr->bssDescription.channelId ==
1007 ptemp->bssDescription.channelId) &&
Abhinav Kumar2d590282018-06-28 11:45:15 +05301008 (*((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1) ==
1009 *((tANI_U8 *) &ptemp->bssDescription.ieFields + 1)) &&
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301010 vos_mem_compare( ((tANI_U8 *) &pBssDescr->bssDescription.ieFields + 1),
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001011 ((tANI_U8 *) &ptemp->bssDescription.ieFields + 1),
1012 (tANI_U8) (ssidLen + 1)) &&
1013 ((pSirCapTemp->ess) || //we are done for infrastructure
1014 //For IBSS, nwType and channelId
1015 (((pBssDescr->bssDescription.nwType ==
1016 ptemp->bssDescription.nwType) &&
1017 (pBssDescr->bssDescription.channelId ==
1018 ptemp->bssDescription.channelId))))
1019 )
1020 {
1021 // Found the same BSS description
1022 if (action == LIM_HASH_UPDATE)
1023 {
1024 if(dontUpdateAll)
1025 {
1026 rssi = ptemp->bssDescription.rssi;
1027 }
1028
1029 if(pBssDescr->bssDescription.fProbeRsp != ptemp->bssDescription.fProbeRsp)
1030 {
1031 //We get a different, save the old frame WSC IE if it is there
1032 idx = 0;
1033 len = ptemp->bssDescription.length - sizeof(tSirBssDescription) +
1034 sizeof(tANI_U16) + sizeof(tANI_U32) - DOT11F_IE_WSCPROBERES_MIN_LEN - 2;
1035 pbIe = (tANI_U8 *)ptemp->bssDescription.ieFields;
1036 //Save WPS IE if it exists
1037 pBssDescr->bssDescription.WscIeLen = 0;
1038 while(idx < len)
1039 {
1040 if((DOT11F_EID_WSCPROBERES == pbIe[0]) &&
1041 (0x00 == pbIe[2]) && (0x50 == pbIe[3]) &&
1042 (0xf2 == pbIe[4]) && (0x04 == pbIe[5]))
1043 {
1044 //Found it
1045 if((DOT11F_IE_WSCPROBERES_MAX_LEN - 2) >= pbIe[1])
1046 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301047 vos_mem_copy( pBssDescr->bssDescription.WscIeProbeRsp,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001048 pbIe, pbIe[1] + 2);
1049 pBssDescr->bssDescription.WscIeLen = pbIe[1] + 2;
1050 }
1051 break;
1052 }
1053 idx += pbIe[1] + 2;
1054 pbIe += pbIe[1] + 2;
1055 }
1056 }
1057
1058
1059 if(NULL != pMac->lim.gpLimMlmScanReq)
1060 {
1061 if((pMac->lim.gpLimMlmScanReq->numSsid)&&
1062 ( limIsNullSsid((tSirMacSSid *)((tANI_U8 *)
1063 &pBssDescr->bssDescription.ieFields + 1))))
1064 return eHAL_STATUS_FAILURE;
1065 }
1066
1067 // Delete this entry
1068 if (ptemp == pMac->lim.gLimCachedLfrScanHashTable[index])
1069 pprev = pMac->lim.gLimCachedLfrScanHashTable[index] = ptemp->next;
1070 else
1071 pprev->next = ptemp->next;
1072
1073 pMac->lim.gLimMlmLfrScanResultLength -=
1074 ptemp->bssDescription.length + sizeof(tANI_U16);
1075
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301076 vos_mem_free(ptemp);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001077 }
1078 break;
1079 }
1080 }
1081
1082 //for now, only rssi, we can add more if needed
1083 if ((action == LIM_HASH_UPDATE) && dontUpdateAll && rssi)
1084 {
1085 pBssDescr->bssDescription.rssi = rssi;
1086 }
1087
1088 // Add this BSS description at same index
1089 if (pprev == pMac->lim.gLimCachedLfrScanHashTable[index])
1090 {
1091 pBssDescr->next = pMac->lim.gLimCachedLfrScanHashTable[index];
1092 pMac->lim.gLimCachedLfrScanHashTable[index] = pBssDescr;
1093 }
1094 else
1095 {
1096 pBssDescr->next = pprev->next;
1097 pprev->next = pBssDescr;
1098 }
1099 pMac->lim.gLimMlmLfrScanResultLength +=
1100 pBssDescr->bssDescription.length + sizeof(tANI_U16);
1101
1102 PELOG2(limLog(pMac, LOG2, FL("Added new BSS description size %d TOT %d BSS id\n"),
1103 pBssDescr->bssDescription.length,
1104 pMac->lim.gLimMlmLfrScanResultLength);
1105 limPrintMacAddr(pMac, pBssDescr->bssDescription.bssId, LOG2);)
1106
1107 //
1108 // TODO: IF applicable, do we need to send:
1109 // Mesg - eWNI_SME_WM_STATUS_CHANGE_NTF
1110 // Status change code - eSIR_SME_CB_LEGACY_BSS_FOUND_BY_AP
1111 //
1112 return eHAL_STATUS_SUCCESS;
1113}
1114
1115
1116
1117/**
1118 * limDeleteLfrHashEntry()
1119 *
1120 *FUNCTION:
1121 * This function is called upon to delete
1122 * a BSS description from LFR scan result hash table.
1123 *
1124 *LOGIC:
1125 *
1126 *ASSUMPTIONS:
1127 * NA
1128 *
1129 *NOTE:
1130 * Yet to find the utility of the function
1131 *
1132 * @param pBssDescr - Pointer to BSS description to be
1133 * deleted from the LFR scan result hash table.
1134 *
1135 * @return None
1136 */
1137
1138void limDeleteLfrHashEntry(tLimScanResultNode *pBssDescr)
1139{
1140} /****** end limDeleteLfrHashEntry() ******/
1141
1142#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001143
1144/**
1145 * limCopyScanResult()
1146 *
1147 *FUNCTION:
1148 * This function is called by limProcessSmeMessages() while
1149 * sending SME_SCAN_RSP with scan result to HDD.
1150 *
1151 *LOGIC:
1152 * This function traverses the scan list stored in scan hash table
1153 *
1154 *ASSUMPTIONS:
1155 * NA
1156 *
1157 *NOTE:
1158 * NA
1159 *
1160 * @param pMac - Pointer to Global MAC structure
1161 * @param pDest - Destination pointer
1162 *
1163 * @return None
1164 */
1165
1166void
1167limCopyScanResult(tpAniSirGlobal pMac, tANI_U8 *pDest)
1168{
1169 tLimScanResultNode *ptemp;
1170 tANI_U16 i;
1171 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1172 {
1173 if ((ptemp = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1174 {
1175 while(ptemp)
1176 {
1177 /// Copy entire BSS description including length
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301178 vos_mem_copy( pDest,
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 (tANI_U8 *) &ptemp->bssDescription,
1180 ptemp->bssDescription.length + 2);
1181 pDest += ptemp->bssDescription.length + 2;
1182 ptemp = ptemp->next;
1183 }
1184 }
1185 }
1186} /****** end limCopyScanResult() ******/
1187
1188
1189
1190/**
1191 * limDeleteCachedScanResults()
1192 *
1193 *FUNCTION:
1194 * This function is called by limProcessSmeMessages() upon receiving
1195 * SME_SCAN_REQ with fresh scan result flag set.
1196 *
1197 *LOGIC:
1198 * This function traverses the scan list stored in scan hash table
1199 * and deletes the entries if any
1200 *
1201 *ASSUMPTIONS:
1202 * NA
1203 *
1204 *NOTE:
1205 * NA
1206 *
1207 * @param pMac - Pointer to Global MAC structure
1208 * @return None
1209 */
1210
1211void
1212limDeleteCachedScanResults(tpAniSirGlobal pMac)
1213{
1214 tLimScanResultNode *pNode, *pNextNode;
1215 tANI_U16 i;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301216
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1218 {
1219 if ((pNode = pMac->lim.gLimCachedScanHashTable[i]) != NULL)
1220 {
1221 while (pNode)
1222 {
1223 pNextNode = pNode->next;
1224
1225 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301226 vos_mem_free(pNode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001227
1228 pNode = pNextNode;
1229 }
1230 }
1231 }
1232
1233 pMac->lim.gLimSmeScanResultLength = 0;
1234} /****** end limDeleteCachedScanResults() ******/
1235
1236
1237
1238/**
1239 * limReInitScanResults()
1240 *
1241 *FUNCTION:
1242 * This function is called delete exisiting scan results
1243 * and initialize the scan hash table
1244 *
1245 *LOGIC:
1246 *
1247 *ASSUMPTIONS:
1248 * NA
1249 *
1250 *NOTE:
1251 * NA
1252 *
1253 * @param pMac - Pointer to Global MAC structure
1254 * @return None
1255 */
1256
1257void
1258limReInitScanResults(tpAniSirGlobal pMac)
1259{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301260 limLog(pMac, LOG1, FL("Re initialize scan hash table."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001261 limDeleteCachedScanResults(pMac);
1262 limInitHashTable(pMac);
1263
1264 // !!LAC - need to clear out the global scan result length
1265 // since the list was just purged from the hash table.
1266 pMac->lim.gLimMlmScanResultLength = 0;
1267
1268} /****** end limReInitScanResults() ******/
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001269#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1270/**
1271 * limDeleteCachedLfrScanResults()
1272 *
1273 *FUNCTION:
1274 * This function is called by limProcessSmeMessages() upon receiving
1275 * SME_SCAN_REQ with flush scan result flag set for LFR.
1276 *
1277 *LOGIC:
1278 * This function traverses the scan list stored in lfr scan hash
1279 * table and deletes the entries if any
1280 *
1281 *ASSUMPTIONS:
1282 * NA
1283 *
1284 *NOTE:
1285 * NA
1286 *
1287 * @param pMac - Pointer to Global MAC structure
1288 * @return None
1289 */
1290
1291void
1292limDeleteCachedLfrScanResults(tpAniSirGlobal pMac)
1293{
1294 tLimScanResultNode *pNode, *pNextNode;
1295 tANI_U16 i;
1296 for (i = 0; i < LIM_MAX_NUM_OF_SCAN_RESULTS; i++)
1297 {
1298 if ((pNode = pMac->lim.gLimCachedLfrScanHashTable[i]) != NULL)
1299 {
1300 while (pNode)
1301 {
1302 pNextNode = pNode->next;
1303
1304 // Delete the current node
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301305 vos_mem_free(pNode);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001306
1307 pNode = pNextNode;
1308 }
1309 }
1310 }
1311
1312 pMac->lim.gLimSmeLfrScanResultLength = 0;
1313} /****** end limDeleteCachedLfrScanResults() ******/
1314
1315
1316
1317/**
1318 * limReInitLfrScanResults()
1319 *
1320 *FUNCTION:
1321 * This function is called delete exisiting scan results
1322 * and initialize the lfr scan hash table
1323 *
1324 *LOGIC:
1325 *
1326 *ASSUMPTIONS:
1327 * NA
1328 *
1329 *NOTE:
1330 * NA
1331 *
1332 * @param pMac - Pointer to Global MAC structure
1333 * @return None
1334 */
1335
1336void
1337limReInitLfrScanResults(tpAniSirGlobal pMac)
1338{
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301339 limLog(pMac, LOG1, FL("Re initialize lfr scan hash table."));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001340 limDeleteCachedLfrScanResults(pMac);
1341 limInitLfrHashTable(pMac);
1342
1343 // !!LAC - need to clear out the global scan result length
1344 // since the list was just purged from the hash table.
1345 pMac->lim.gLimMlmLfrScanResultLength = 0;
1346
1347} /****** end limReInitLfrScanResults() ******/
1348#endif //WLAN_FEATURE_ROAM_SCAN_OFFLOAD