import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6630 / wlan / mgmt / scan_fsm.c
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/scan_fsm.c#2 $
3 */
4
5 /*! \file "scan_fsm.c"
6 \brief This file defines the state transition function for SCAN FSM.
7
8 The SCAN FSM is part of SCAN MODULE and responsible for performing basic SCAN
9 behavior as metioned in IEEE 802.11 2007 11.1.3.1 & 11.1.3.2 .
10 */
11
12
13
14 /*
15 ** $Log: scan_fsm.c $
16 **
17 ** 08 15 2013 cp.wu
18 ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
19 ** enlarge match_ssid_num to 16 for PNO support
20 **
21 ** 08 09 2013 cp.wu
22 ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
23 ** 1. integrate scheduled scan functionality
24 ** 2. condition compilation for linux-3.4 & linux-3.8 compatibility
25 ** 3. correct CMD queue access to reduce lock scope
26 **
27 ** 02 19 2013 cp.wu
28 ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
29 ** take use of GET_BSS_INFO_BY_INDEX() and MAX_BSS_INDEX macros
30 ** for correctly indexing of BSS-INFO pointers
31 **
32 ** 02 05 2013 cp.wu
33 ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
34 ** 1. change to use long format (FT=1) for initial command
35 ** 2. fix a typo
36 **
37 ** 01 22 2013 cp.wu
38 ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
39 ** .add driver side NLO state machine
40 **
41 ** 01 22 2013 cp.wu
42 ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
43 ** modification for ucBssIndex migration
44 **
45 ** 01 03 2013 cp.wu
46 ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
47 ** carry timeout value and channel dwell time value to scan module
48 **
49 ** 09 17 2012 cm.chang
50 ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
51 ** Duplicate source from MT6620 v2.3 driver branch
52 ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
53 **
54 ** 08 31 2012 cp.wu
55 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
56 ** do not use fgIsP2PRegistered for checking but use network index
57 *
58 * 06 13 2012 yuche.tsai
59 * NULL
60 * Update maintrunk driver.
61 * Add support for driver compose assoc request frame.
62 *
63 * 11 24 2011 wh.su
64 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
65 * Adjust code for DBG and CONFIG_XLOG.
66 *
67 * 11 14 2011 yuche.tsai
68 * [WCXRP00001095] [Volunteer Patch][Driver] Always Scan before enable Hot-Spot.
69 * Fix bug when unregister P2P network..
70 *
71 * 11 11 2011 wh.su
72 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
73 * modify the xlog related code.
74 *
75 * 11 02 2011 wh.su
76 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
77 * adding the code for XLOG.
78 *
79 * 08 11 2011 cp.wu
80 * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
81 * sparse channel detection:
82 * driver: collect sparse channel information with scan-done event
83
84 *
85 * 07 18 2011 cp.wu
86 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
87 * free mailbox message afte parsing is completed.
88 *
89 * 07 18 2011 cp.wu
90 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
91 * add framework in driver domain for supporting new SCAN_REQ_V2 for more than 1 SSID support as well as uProbeDelay in NDIS 6.x driver model
92 *
93 * 04 18 2011 terry.wu
94 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
95 * Remove flag CFG_WIFI_DIRECT_MOVED.
96 *
97 * 03 29 2011 cp.wu
98 * [WCXRP00000604] [MT6620 Wi-Fi][Driver] Surpress Klockwork Warning
99 * surpress klock warning with code path rewritten
100 *
101 * 03 18 2011 cm.chang
102 * [WCXRP00000576] [MT6620 Wi-Fi][Driver][FW] Remove P2P compile option in scan req/cancel command
103 * As CR title
104 *
105 * 02 18 2011 yuche.tsai
106 * [WCXRP00000478] [Volunteer Patch][MT6620][Driver] Probe request frame during search phase do not contain P2P wildcard SSID.
107 * Take P2P wildcard SSID into consideration.
108 *
109 * 01 27 2011 yuche.tsai
110 * [WCXRP00000399] [Volunteer Patch][MT6620/MT5931][Driver] Fix scan side effect after P2P module separate.
111 * Fix scan channel extension issue when p2p module is not registered.
112 *
113 * 01 26 2011 yuche.tsai
114 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
115 * .
116 *
117 * 01 25 2011 yuche.tsai
118 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
119 * Fix Compile Error when DBG is disabled.
120 *
121 * 12 07 2010 cm.chang
122 * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
123 * 1. Country code is from NVRAM or supplicant
124 * 2. Change band definition in CMD/EVENT.
125 *
126 * 09 03 2010 kevin.huang
127 * NULL
128 * Refine #include sequence and solve recursive/nested #include issue
129 *
130 * 08 30 2010 cp.wu
131 * NULL
132 * eliminate klockwork errors
133 *
134 * 08 16 2010 cp.wu
135 * NULL
136 * add interface for RLM to trigger OBSS-SCAN.
137 *
138 * 08 16 2010 yuche.tsai
139 * NULL
140 * Fix bug for processing queued scan request.
141 *
142 * 08 11 2010 yuche.tsai
143 * NULL
144 * Add a function for returning channel.
145 *
146 * 08 05 2010 yuche.tsai
147 * NULL
148 * Update SCAN FSM for support P2P Device discovery scan.
149 *
150 * 08 03 2010 cp.wu
151 * NULL
152 * surpress compilation warning.
153 *
154 * 07 26 2010 yuche.tsai
155 *
156 * Add option of channel extension while cancelling scan request.
157 *
158 * 07 21 2010 yuche.tsai
159 *
160 * Add P2P Scan & Scan Result Parsing & Saving.
161 *
162 * 07 20 2010 cp.wu
163 *
164 * pass band information for scan in an efficient way by mapping ENUM_BAND_T into UINT_8..
165 *
166 * 07 19 2010 cp.wu
167 *
168 * due to FW/DRV won't be sync. precisely, some strict assertions should be eased.
169 *
170 * 07 19 2010 cp.wu
171 *
172 * [WPD00003833] [MT6620 and MT5931] Driver migration.
173 * SCN module is now able to handle multiple concurrent scanning requests
174 *
175 * 07 16 2010 cp.wu
176 *
177 * [WPD00003833] [MT6620 and MT5931] Driver migration.
178 * bugfix for SCN migration
179 * 1) modify QUEUE_CONCATENATE_QUEUES() so it could be used to concatence with an empty queue
180 * 2) before AIS issues scan request, network(BSS) needs to be activated first
181 * 3) only invoke COPY_SSID when using specified SSID for scan
182 *
183 * 07 15 2010 cp.wu
184 *
185 * [WPD00003833] [MT6620 and MT5931] Driver migration.
186 * driver no longer generates probe request frames
187 *
188 * 07 14 2010 cp.wu
189 *
190 * [WPD00003833] [MT6620 and MT5931] Driver migration.
191 * pass band with channel number information as scan parameter
192 *
193 * 07 14 2010 cp.wu
194 *
195 * [WPD00003833] [MT6620 and MT5931] Driver migration.
196 * remove timer in DRV-SCN.
197 *
198 * 07 09 2010 cp.wu
199 *
200 * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
201 * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
202 * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
203 *
204 * 07 08 2010 cp.wu
205 *
206 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
207 *
208 * 07 08 2010 cp.wu
209 * [WPD00003833][MT6620 and MT5931] Driver migration
210 * take use of RLM module for parsing/generating HT IEs for 11n capability
211 *
212 * 07 02 2010 cp.wu
213 * [WPD00003833][MT6620 and MT5931] Driver migration
214 * when returning to SCAN_IDLE state, send a correct message to source FSM.
215 *
216 * 07 01 2010 cp.wu
217 * [WPD00003833][MT6620 and MT5931] Driver migration
218 * implementation of DRV-SCN and related mailbox message handling.
219 *
220 * 06 22 2010 cp.wu
221 * [WPD00003833][MT6620 and MT5931] Driver migration
222 * comment out RLM APIs by CFG_RLM_MIGRATION.
223 *
224 * 06 21 2010 cp.wu
225 * [WPD00003833][MT6620 and MT5931] Driver migration
226 * add scan_fsm into building.
227 *
228 * 05 14 2010 kevin.huang
229 * [BORA00000794][WIFISYS][New Feature]Power Management Support
230 * Refine the order of Stop TX Queue and Switch Channel
231 *
232 * 05 12 2010 kevin.huang
233 * [BORA00000794][WIFISYS][New Feature]Power Management Support
234 * Update pause/resume/flush API to new Bitmap API
235 *
236 * 05 12 2010 kevin.huang
237 * [BORA00000794][WIFISYS][New Feature]Power Management Support
238 * Add Power Management - Legacy PS-POLL support.
239 *
240 * 03 18 2010 kevin.huang
241 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
242 * Ignore the PROBE_DELAY state if the value of Probe Delay == 0
243 *
244 * 03 10 2010 kevin.huang
245 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
246 * Add Channel Manager for arbitration of JOIN and SCAN Req
247 *
248 * 02 23 2010 kevin.huang
249 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
250 * Add support scan channel 1~14 and update scan result's frequency infou1rwduu`wvpghlqg|n`slk+mpdkb
251 *
252 * 01 08 2010 kevin.huang
253 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
254 * Add set RX Filter to receive BCN from different BSSID during SCAN
255 *
256 * 12 18 2009 cm.chang
257 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
258 * .
259 *
260 * Nov 25 2009 mtk01461
261 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
262 * Remove flag of CFG_TEST_MGMT_FSM
263 *
264 * Nov 20 2009 mtk01461
265 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
266 * Change parameter of scanSendProbeReqFrames()
267 *
268 * Nov 16 2009 mtk01461
269 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
270 * Update scnFsmSteps()
271 *
272 * Nov 5 2009 mtk01461
273 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
274 * Fix typo
275 *
276 * Nov 5 2009 mtk01461
277 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
278 *
279 */
280
281 /*******************************************************************************
282 * C O M P I L E R F L A G S
283 ********************************************************************************
284 */
285
286 /*******************************************************************************
287 * E X T E R N A L R E F E R E N C E S
288 ********************************************************************************
289 */
290 #include "precomp.h"
291
292 /*******************************************************************************
293 * C O N S T A N T S
294 ********************************************************************************
295 */
296
297 /*******************************************************************************
298 * D A T A T Y P E S
299 ********************************************************************************
300 */
301
302 /*******************************************************************************
303 * P U B L I C D A T A
304 ********************************************************************************
305 */
306
307 /*******************************************************************************
308 * P R I V A T E D A T A
309 ********************************************************************************
310 */
311 #if DBG
312 /*lint -save -e64 Type mismatch */
313 static PUINT_8 apucDebugScanState[SCAN_STATE_NUM] = {
314 (PUINT_8) DISP_STRING("SCAN_STATE_IDLE"),
315 (PUINT_8) DISP_STRING("SCAN_STATE_SCANNING"),
316 };
317
318 /*lint -restore */
319 #endif /* DBG */
320
321 /*******************************************************************************
322 * M A C R O S
323 ********************************************************************************
324 */
325
326 /*******************************************************************************
327 * F U N C T I O N D E C L A R A T I O N S
328 ********************************************************************************
329 */
330
331 /*******************************************************************************
332 * F U N C T I O N S
333 ********************************************************************************
334 */
335 /*----------------------------------------------------------------------------*/
336 /*!
337 * \brief
338 *
339 * \param[in]
340 *
341 * \return none
342 */
343 /*----------------------------------------------------------------------------*/
344 VOID scnFsmSteps(IN P_ADAPTER_T prAdapter, IN ENUM_SCAN_STATE_T eNextState)
345 {
346 P_SCAN_INFO_T prScanInfo;
347 P_SCAN_PARAM_T prScanParam;
348 P_MSG_HDR_T prMsgHdr;
349
350 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
351
352 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
353 prScanParam = &prScanInfo->rScanParam;
354
355 do {
356
357 #if DBG
358 DBGLOG(SCN, STATE, ("TRANSITION: [%s] -> [%s]\n",
359 apucDebugScanState[prScanInfo->eCurrentState],
360 apucDebugScanState[eNextState]));
361 #else
362 DBGLOG(SCN, STATE, ("[%d] TRANSITION: [%d] -> [%d]\n",
363 DBG_SCN_IDX, prScanInfo->eCurrentState, eNextState));
364 #endif
365
366 /* NOTE(Kevin): This is the only place to change the eCurrentState(except initial) */
367 prScanInfo->eCurrentState = eNextState;
368
369 fgIsTransition = (BOOLEAN) FALSE;
370
371 switch (prScanInfo->eCurrentState) {
372 case SCAN_STATE_IDLE:
373 /* check for pending scanning requests */
374 if (!LINK_IS_EMPTY(&(prScanInfo->rPendingMsgList))) {
375 /* load next message from pending list as scan parameters */
376 LINK_REMOVE_HEAD(&(prScanInfo->rPendingMsgList), prMsgHdr,
377 P_MSG_HDR_T);
378
379 if (prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
380 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
381 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
382 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
383 scnFsmHandleScanMsg(prAdapter,
384 (P_MSG_SCN_SCAN_REQ) prMsgHdr);
385
386 eNextState = SCAN_STATE_SCANNING;
387 fgIsTransition = TRUE;
388 } else if (prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
389 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
390 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
391 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
392 scnFsmHandleScanMsgV2(prAdapter,
393 (P_MSG_SCN_SCAN_REQ_V2) prMsgHdr);
394
395 eNextState = SCAN_STATE_SCANNING;
396 fgIsTransition = TRUE;
397 } else {
398 /* should not happen */
399 ASSERT(0);
400 }
401
402 /* switch to next state */
403 cnmMemFree(prAdapter, prMsgHdr);
404 }
405 break;
406
407 case SCAN_STATE_SCANNING:
408 if (prScanParam->fgIsScanV2 == FALSE) {
409 scnSendScanReq(prAdapter);
410 } else {
411 scnSendScanReqV2(prAdapter);
412 }
413 break;
414
415 default:
416 ASSERT(0);
417 break;
418
419 }
420 } while (fgIsTransition);
421
422 return;
423 }
424
425
426 /*----------------------------------------------------------------------------*/
427 /*!
428 * \brief Generate CMD_ID_SCAN_REQ command
429 *
430 * \param[in]
431 *
432 * \return none
433 */
434 /*----------------------------------------------------------------------------*/
435 VOID scnSendScanReq(IN P_ADAPTER_T prAdapter)
436 {
437 P_SCAN_INFO_T prScanInfo;
438 P_SCAN_PARAM_T prScanParam;
439 CMD_SCAN_REQ rCmdScanReq;
440 UINT_32 i;
441
442 ASSERT(prAdapter);
443
444 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
445 prScanParam = &prScanInfo->rScanParam;
446
447 /* send command packet for scan */
448 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ));
449
450 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
451 rCmdScanReq.ucBssIndex = prScanParam->ucBssIndex;
452 rCmdScanReq.ucScanType = (UINT_8) prScanParam->eScanType;
453 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
454
455 if (prScanParam->ucSSIDNum == 1) {
456 COPY_SSID(rCmdScanReq.aucSSID,
457 rCmdScanReq.ucSSIDLength,
458 prScanParam->aucSpecifiedSSID[0], prScanParam->ucSpecifiedSSIDLen[0]);
459 }
460
461 rCmdScanReq.ucChannelType = (UINT_8) prScanParam->eScanChannel;
462
463 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
464 /* P2P would use:
465 * 1. Specified Listen Channel of passive scan for LISTEN state.
466 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
467 */
468 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
469
470 for (i = 0; i < rCmdScanReq.ucChannelListNum; i++) {
471 rCmdScanReq.arChannelList[i].ucBand =
472 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
473
474 rCmdScanReq.arChannelList[i].ucChannelNum =
475 (UINT_8) prScanParam->arChnlInfoList[i].ucChannelNum;
476 }
477 }
478
479 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2ChannelDwellTime;
480 rCmdScanReq.u2TimeoutValue = prScanParam->u2TimeoutValue;
481
482 if (prScanParam->u2IELen <= MAX_IE_LENGTH) {
483 rCmdScanReq.u2IELen = prScanParam->u2IELen;
484 } else {
485 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
486 }
487
488 if (prScanParam->u2IELen) {
489 kalMemCopy(rCmdScanReq.aucIE,
490 prScanParam->aucIE, sizeof(UINT_8) * rCmdScanReq.u2IELen);
491 }
492
493 wlanSendSetQueryCmd(prAdapter,
494 CMD_ID_SCAN_REQ,
495 TRUE,
496 FALSE,
497 FALSE,
498 NULL,
499 NULL,
500 OFFSET_OF(CMD_SCAN_REQ, aucIE) + rCmdScanReq.u2IELen,
501 (PUINT_8) &rCmdScanReq, NULL, 0);
502 }
503
504
505 /*----------------------------------------------------------------------------*/
506 /*!
507 * \brief Generate CMD_ID_SCAN_REQ_V2 command
508 *
509 * \param[in]
510 *
511 * \return none
512 */
513 /*----------------------------------------------------------------------------*/
514 VOID scnSendScanReqV2(IN P_ADAPTER_T prAdapter)
515 {
516 P_SCAN_INFO_T prScanInfo;
517 P_SCAN_PARAM_T prScanParam;
518 CMD_SCAN_REQ_V2 rCmdScanReq;
519 UINT_32 i;
520
521 ASSERT(prAdapter);
522
523 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
524 prScanParam = &prScanInfo->rScanParam;
525
526 /* send command packet for scan */
527 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ_V2));
528
529 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
530 rCmdScanReq.ucBssIndex = prScanParam->ucBssIndex;
531 rCmdScanReq.ucScanType = (UINT_8) prScanParam->eScanType;
532 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
533
534 for (i = 0; i < prScanParam->ucSSIDNum; i++) {
535 COPY_SSID(rCmdScanReq.arSSID[i].aucSsid,
536 rCmdScanReq.arSSID[i].u4SsidLen,
537 prScanParam->aucSpecifiedSSID[i], prScanParam->ucSpecifiedSSIDLen[i]);
538 }
539
540 rCmdScanReq.u2ProbeDelayTime = (UINT_8) prScanParam->u2ProbeDelayTime;
541 rCmdScanReq.ucChannelType = (UINT_8) prScanParam->eScanChannel;
542
543 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
544 /* P2P would use:
545 * 1. Specified Listen Channel of passive scan for LISTEN state.
546 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
547 */
548 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
549
550 for (i = 0; i < rCmdScanReq.ucChannelListNum; i++) {
551 rCmdScanReq.arChannelList[i].ucBand =
552 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
553
554 rCmdScanReq.arChannelList[i].ucChannelNum =
555 (UINT_8) prScanParam->arChnlInfoList[i].ucChannelNum;
556 }
557 }
558
559 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2ChannelDwellTime;
560 rCmdScanReq.u2TimeoutValue = prScanParam->u2TimeoutValue;
561
562 if (prScanParam->u2IELen <= MAX_IE_LENGTH) {
563 rCmdScanReq.u2IELen = prScanParam->u2IELen;
564 } else {
565 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
566 }
567
568 if (prScanParam->u2IELen) {
569 kalMemCopy(rCmdScanReq.aucIE,
570 prScanParam->aucIE, sizeof(UINT_8) * rCmdScanReq.u2IELen);
571 }
572
573 wlanSendSetQueryCmd(prAdapter,
574 CMD_ID_SCAN_REQ_V2,
575 TRUE,
576 FALSE,
577 FALSE,
578 NULL,
579 NULL,
580 OFFSET_OF(CMD_SCAN_REQ_V2, aucIE) + rCmdScanReq.u2IELen,
581 (PUINT_8) &rCmdScanReq, NULL, 0);
582
583 }
584
585
586 /*----------------------------------------------------------------------------*/
587 /*!
588 * \brief
589 *
590 * \param[in]
591 *
592 * \return none
593 */
594 /*----------------------------------------------------------------------------*/
595 VOID scnFsmMsgStart(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
596 {
597 P_SCAN_INFO_T prScanInfo;
598 P_SCAN_PARAM_T prScanParam;
599
600 ASSERT(prMsgHdr);
601
602 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
603 prScanParam = &prScanInfo->rScanParam;
604
605
606 if (prScanInfo->eCurrentState == SCAN_STATE_IDLE) {
607 if (prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
608 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
609 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
610 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
611 scnFsmHandleScanMsg(prAdapter, (P_MSG_SCN_SCAN_REQ) prMsgHdr);
612 } else if (prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
613 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
614 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
615 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
616 scnFsmHandleScanMsgV2(prAdapter, (P_MSG_SCN_SCAN_REQ_V2) prMsgHdr);
617 } else {
618 /* should not deliver to this function */
619 ASSERT(0);
620 }
621
622 cnmMemFree(prAdapter, prMsgHdr);
623 scnFsmSteps(prAdapter, SCAN_STATE_SCANNING);
624 } else {
625 LINK_INSERT_TAIL(&prScanInfo->rPendingMsgList, &prMsgHdr->rLinkEntry);
626 }
627
628 return;
629 }
630
631
632
633 /*----------------------------------------------------------------------------*/
634 /*!
635 * \brief
636 *
637 * \param[in]
638 *
639 * \return none
640 */
641 /*----------------------------------------------------------------------------*/
642 VOID scnFsmMsgAbort(IN P_ADAPTER_T prAdapter, IN P_MSG_HDR_T prMsgHdr)
643 {
644 P_MSG_SCN_SCAN_CANCEL prScanCancel;
645 P_SCAN_INFO_T prScanInfo;
646 P_SCAN_PARAM_T prScanParam;
647 CMD_SCAN_CANCEL rCmdScanCancel;
648
649 ASSERT(prMsgHdr);
650
651 prScanCancel = (P_MSG_SCN_SCAN_CANCEL) prMsgHdr;
652 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
653 prScanParam = &prScanInfo->rScanParam;
654
655 if (prScanInfo->eCurrentState != SCAN_STATE_IDLE) {
656 if (prScanCancel->ucSeqNum == prScanParam->ucSeqNum &&
657 prScanCancel->ucBssIndex == prScanParam->ucBssIndex) {
658 /* send cancel message to firmware domain */
659 rCmdScanCancel.ucSeqNum = prScanParam->ucSeqNum;
660 rCmdScanCancel.ucIsExtChannel = (UINT_8) prScanCancel->fgIsChannelExt;
661
662 wlanSendSetQueryCmd(prAdapter,
663 CMD_ID_SCAN_CANCEL,
664 TRUE,
665 FALSE,
666 FALSE,
667 NULL,
668 NULL,
669 sizeof(CMD_SCAN_CANCEL),
670 (PUINT_8) &rCmdScanCancel, NULL, 0);
671
672 /* generate scan-done event for caller */
673 scnFsmGenerateScanDoneMsg(prAdapter,
674 prScanParam->ucSeqNum,
675 prScanParam->ucBssIndex, SCAN_STATUS_CANCELLED);
676
677 /* switch to next pending scan */
678 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
679 } else {
680 scnFsmRemovePendingMsg(prAdapter, prScanCancel->ucSeqNum,
681 prScanCancel->ucBssIndex);
682 }
683 }
684
685 cnmMemFree(prAdapter, prMsgHdr);
686
687 return;
688 }
689
690
691 /*----------------------------------------------------------------------------*/
692 /*!
693 * \brief Scan Message Parsing (Legacy)
694 *
695 * \param[in]
696 *
697 * \return none
698 */
699 /*----------------------------------------------------------------------------*/
700 VOID scnFsmHandleScanMsg(IN P_ADAPTER_T prAdapter, IN P_MSG_SCN_SCAN_REQ prScanReqMsg)
701 {
702 P_SCAN_INFO_T prScanInfo;
703 P_SCAN_PARAM_T prScanParam;
704 UINT_32 i;
705
706 ASSERT(prAdapter);
707 ASSERT(prScanReqMsg);
708
709 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
710 prScanParam = &prScanInfo->rScanParam;
711
712 prScanParam->eScanType = prScanReqMsg->eScanType;
713 prScanParam->ucBssIndex = prScanReqMsg->ucBssIndex;
714 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
715 if (prScanParam->ucSSIDType & (SCAN_REQ_SSID_SPECIFIED | SCAN_REQ_SSID_P2P_WILDCARD)) {
716 prScanParam->ucSSIDNum = 1;
717
718 COPY_SSID(prScanParam->aucSpecifiedSSID[0],
719 prScanParam->ucSpecifiedSSIDLen[0],
720 prScanReqMsg->aucSSID, prScanReqMsg->ucSSIDLength);
721
722 /* reset SSID length to zero for rest array entries */
723 for (i = 1; i < SCN_SSID_MAX_NUM; i++) {
724 prScanParam->ucSpecifiedSSIDLen[i] = 0;
725 }
726 } else {
727 prScanParam->ucSSIDNum = 0;
728
729 for (i = 0; i < SCN_SSID_MAX_NUM; i++) {
730 prScanParam->ucSpecifiedSSIDLen[i] = 0;
731 }
732 }
733
734 prScanParam->u2ProbeDelayTime = 0;
735 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
736 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
737 if (prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
738 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
739 } else {
740 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
741 }
742
743 kalMemCopy(prScanParam->arChnlInfoList,
744 prScanReqMsg->arChnlInfoList,
745 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
746 }
747
748 if (prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
749 prScanParam->u2IELen = prScanReqMsg->u2IELen;
750 } else {
751 prScanParam->u2IELen = MAX_IE_LENGTH;
752 }
753
754 if (prScanParam->u2IELen) {
755 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
756 }
757
758 prScanParam->u2ChannelDwellTime = prScanReqMsg->u2ChannelDwellTime;
759 prScanParam->u2TimeoutValue = prScanReqMsg->u2TimeoutValue;
760 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
761
762 if (prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
763 prScanParam->fgIsObssScan = TRUE;
764 } else {
765 prScanParam->fgIsObssScan = FALSE;
766 }
767
768 prScanParam->fgIsScanV2 = FALSE;
769
770 return;
771 }
772
773
774 /*----------------------------------------------------------------------------*/
775 /*!
776 * \brief Scan Message Parsing - V2 with multiple SSID support
777 *
778 * \param[in]
779 *
780 * \return none
781 */
782 /*----------------------------------------------------------------------------*/
783 VOID scnFsmHandleScanMsgV2(IN P_ADAPTER_T prAdapter, IN P_MSG_SCN_SCAN_REQ_V2 prScanReqMsg)
784 {
785 P_SCAN_INFO_T prScanInfo;
786 P_SCAN_PARAM_T prScanParam;
787 UINT_32 i;
788
789 ASSERT(prAdapter);
790 ASSERT(prScanReqMsg);
791 ASSERT(prScanReqMsg->ucSSIDNum <= SCN_SSID_MAX_NUM);
792
793 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
794 prScanParam = &prScanInfo->rScanParam;
795
796 prScanParam->eScanType = prScanReqMsg->eScanType;
797 prScanParam->ucBssIndex = prScanReqMsg->ucBssIndex;
798 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
799 prScanParam->ucSSIDNum = prScanReqMsg->ucSSIDNum;
800
801 for (i = 0; i < prScanReqMsg->ucSSIDNum; i++) {
802 COPY_SSID(prScanParam->aucSpecifiedSSID[i],
803 prScanParam->ucSpecifiedSSIDLen[i],
804 prScanReqMsg->prSsid[i].aucSsid,
805 (UINT_8) prScanReqMsg->prSsid[i].u4SsidLen);
806 }
807
808 prScanParam->u2ProbeDelayTime = prScanReqMsg->u2ProbeDelay;
809 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
810 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
811 if (prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
812 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
813 } else {
814 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
815 }
816
817 kalMemCopy(prScanParam->arChnlInfoList,
818 prScanReqMsg->arChnlInfoList,
819 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
820 }
821
822 if (prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
823 prScanParam->u2IELen = prScanReqMsg->u2IELen;
824 } else {
825 prScanParam->u2IELen = MAX_IE_LENGTH;
826 }
827
828 if (prScanParam->u2IELen) {
829 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
830 }
831
832 prScanParam->u2ChannelDwellTime = prScanReqMsg->u2ChannelDwellTime;
833 prScanParam->u2TimeoutValue = prScanReqMsg->u2TimeoutValue;
834 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
835
836 if (prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
837 prScanParam->fgIsObssScan = TRUE;
838 } else {
839 prScanParam->fgIsObssScan = FALSE;
840 }
841
842 prScanParam->fgIsScanV2 = TRUE;
843
844 return;
845 }
846
847
848 /*----------------------------------------------------------------------------*/
849 /*!
850 * \brief Remove pending scan request
851 *
852 * \param[in]
853 *
854 * \return none
855 */
856 /*----------------------------------------------------------------------------*/
857 VOID scnFsmRemovePendingMsg(IN P_ADAPTER_T prAdapter, IN UINT_8 ucSeqNum, IN UINT_8 ucBssIndex)
858 {
859 P_SCAN_INFO_T prScanInfo;
860 P_SCAN_PARAM_T prScanParam;
861 P_MSG_HDR_T prPendingMsgHdr, prPendingMsgHdrNext, prRemoveMsgHdr = NULL;
862 P_LINK_ENTRY_T prRemoveLinkEntry = NULL;
863 BOOLEAN fgIsRemovingScan = FALSE;
864
865 ASSERT(prAdapter);
866
867 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
868 prScanParam = &prScanInfo->rScanParam;
869
870 /* traverse through rPendingMsgList for removal */
871 LINK_FOR_EACH_ENTRY_SAFE(prPendingMsgHdr,
872 prPendingMsgHdrNext,
873 &(prScanInfo->rPendingMsgList), rLinkEntry, MSG_HDR_T) {
874 if (prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
875 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
876 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
877 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
878 P_MSG_SCN_SCAN_REQ prScanReqMsg = (P_MSG_SCN_SCAN_REQ) prPendingMsgHdr;
879
880 if (ucSeqNum == prScanReqMsg->ucSeqNum &&
881 ucBssIndex == prScanReqMsg->ucBssIndex) {
882 prRemoveLinkEntry = &(prScanReqMsg->rMsgHdr.rLinkEntry);
883 prRemoveMsgHdr = prPendingMsgHdr;
884 fgIsRemovingScan = TRUE;
885 }
886 } else if (prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
887 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
888 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
889 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
890 P_MSG_SCN_SCAN_REQ_V2 prScanReqMsgV2 =
891 (P_MSG_SCN_SCAN_REQ_V2) prPendingMsgHdr;
892
893 if (ucSeqNum == prScanReqMsgV2->ucSeqNum &&
894 ucBssIndex == prScanReqMsgV2->ucBssIndex) {
895 prRemoveLinkEntry = &(prScanReqMsgV2->rMsgHdr.rLinkEntry);
896 prRemoveMsgHdr = prPendingMsgHdr;
897 fgIsRemovingScan = TRUE;
898 }
899 }
900
901 if (prRemoveLinkEntry) {
902 if (fgIsRemovingScan == TRUE) {
903 /* generate scan-done event for caller */
904 scnFsmGenerateScanDoneMsg(prAdapter,
905 ucSeqNum,
906 ucBssIndex, SCAN_STATUS_CANCELLED);
907 }
908
909 /* remove from pending list */
910 LINK_REMOVE_KNOWN_ENTRY(&(prScanInfo->rPendingMsgList), prRemoveLinkEntry);
911 cnmMemFree(prAdapter, prRemoveMsgHdr);
912
913 break;
914 }
915 }
916
917 return;
918 }
919
920
921 /*----------------------------------------------------------------------------*/
922 /*!
923 * \brief
924 *
925 * \param[in]
926 *
927 * \return none
928 */
929 /*----------------------------------------------------------------------------*/
930 VOID scnEventScanDone(IN P_ADAPTER_T prAdapter, IN P_EVENT_SCAN_DONE prScanDone)
931 {
932 P_SCAN_INFO_T prScanInfo;
933 P_SCAN_PARAM_T prScanParam;
934
935 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
936 prScanParam = &prScanInfo->rScanParam;
937
938 /* buffer empty channel information */
939 if (prScanParam->eScanChannel == SCAN_CHANNEL_FULL
940 || prScanParam->eScanChannel == SCAN_CHANNEL_2G4) {
941 if (prScanDone->ucSparseChannelValid) {
942 prScanInfo->fgIsSparseChannelValid = TRUE;
943 prScanInfo->rSparseChannel.eBand =
944 (ENUM_BAND_T) prScanDone->rSparseChannel.ucBand;
945 prScanInfo->rSparseChannel.ucChannelNum =
946 prScanDone->rSparseChannel.ucChannelNum;
947 } else {
948 prScanInfo->fgIsSparseChannelValid = FALSE;
949 }
950 }
951
952 if (prScanInfo->eCurrentState == SCAN_STATE_SCANNING &&
953 prScanDone->ucSeqNum == prScanParam->ucSeqNum) {
954 /* generate scan-done event for caller */
955 scnFsmGenerateScanDoneMsg(prAdapter,
956 prScanParam->ucSeqNum,
957 prScanParam->ucBssIndex, SCAN_STATUS_DONE);
958
959 /* switch to next pending scan */
960 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
961 } else {
962 DBGLOG(SCN, LOUD, ("Unexpected SCAN-DONE event: SeqNum = %d, Current State = %d\n",
963 prScanDone->ucSeqNum, prScanInfo->eCurrentState));
964 }
965
966 return;
967 } /* end of scnEventScanDone */
968
969
970 /*----------------------------------------------------------------------------*/
971 /*!
972 * \brief
973 *
974 * \param[in]
975 *
976 * \return none
977 */
978 /*----------------------------------------------------------------------------*/
979 VOID
980 scnFsmGenerateScanDoneMsg(IN P_ADAPTER_T prAdapter,
981 IN UINT_8 ucSeqNum, IN UINT_8 ucBssIndex, IN ENUM_SCAN_STATUS eScanStatus)
982 {
983 P_SCAN_INFO_T prScanInfo;
984 P_SCAN_PARAM_T prScanParam;
985 P_MSG_SCN_SCAN_DONE prScanDoneMsg;
986
987 ASSERT(prAdapter);
988
989 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
990 prScanParam = &prScanInfo->rScanParam;
991
992 prScanDoneMsg =
993 (P_MSG_SCN_SCAN_DONE) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_DONE));
994 if (!prScanDoneMsg) {
995 ASSERT(0); /* Can't indicate SCAN FSM Complete */
996 return;
997 }
998
999 if (prScanParam->fgIsObssScan == TRUE) {
1000 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_RLM_SCAN_DONE;
1001 } else {
1002 switch (GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex)->eNetworkType) {
1003 case NETWORK_TYPE_AIS:
1004 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_AIS_SCAN_DONE;
1005 break;
1006
1007 case NETWORK_TYPE_P2P:
1008 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_P2P_SCAN_DONE;
1009 break;
1010
1011 case NETWORK_TYPE_BOW:
1012 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_BOW_SCAN_DONE;
1013 break;
1014
1015 default:
1016 DBGLOG(SCN, LOUD,
1017 ("Unexpected Network Type: %d\n",
1018 GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex)->eNetworkType));
1019 ASSERT(0);
1020 break;
1021 }
1022 }
1023
1024 prScanDoneMsg->ucSeqNum = ucSeqNum;
1025 prScanDoneMsg->ucBssIndex = ucBssIndex;
1026 prScanDoneMsg->eScanStatus = eScanStatus;
1027
1028 mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prScanDoneMsg, MSG_SEND_METHOD_BUF);
1029
1030 } /* end of scnFsmGenerateScanDoneMsg() */
1031
1032
1033 /*----------------------------------------------------------------------------*/
1034 /*!
1035 * \brief Query for most sparse channel
1036 *
1037 * \param[in]
1038 *
1039 * \return none
1040 */
1041 /*----------------------------------------------------------------------------*/
1042 BOOLEAN
1043 scnQuerySparseChannel(IN P_ADAPTER_T prAdapter,
1044 P_ENUM_BAND_T prSparseBand, PUINT_8 pucSparseChannel)
1045 {
1046 P_SCAN_INFO_T prScanInfo;
1047
1048 ASSERT(prAdapter);
1049
1050 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1051
1052 if (prScanInfo->fgIsSparseChannelValid == TRUE) {
1053 if (prSparseBand) {
1054 *prSparseBand = prScanInfo->rSparseChannel.eBand;
1055 }
1056
1057 if (pucSparseChannel) {
1058 *pucSparseChannel = prScanInfo->rSparseChannel.ucChannelNum;
1059 }
1060
1061 return TRUE;
1062 } else {
1063 return FALSE;
1064 }
1065 }
1066
1067
1068 /*----------------------------------------------------------------------------*/
1069 /*!
1070 * \brief Event handler for NLO done event
1071 *
1072 * \param[in]
1073 *
1074 * \return none
1075 */
1076 /*----------------------------------------------------------------------------*/
1077 VOID scnEventNloDone(IN P_ADAPTER_T prAdapter, IN P_EVENT_NLO_DONE_T prNloDone)
1078 {
1079 P_SCAN_INFO_T prScanInfo;
1080 P_NLO_PARAM_T prNloParam;
1081 P_SCAN_PARAM_T prScanParam;
1082
1083 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1084 prNloParam = &prScanInfo->rNloParam;
1085 prScanParam = &prNloParam->rScanParam;
1086
1087 if (prScanInfo->fgNloScanning == TRUE && prNloDone->ucSeqNum == prScanParam->ucSeqNum) {
1088 kalSchedScanResults(prAdapter->prGlueInfo);
1089
1090 if (prNloParam->fgStopAfterIndication == TRUE) {
1091 prScanInfo->fgNloScanning = FALSE;
1092 }
1093 } else {
1094 DBGLOG(SCN, LOUD, ("Unexpected NLO-DONE event: SeqNum = %d, Current State = %d\n",
1095 prNloDone->ucSeqNum, prScanInfo->eCurrentState));
1096 }
1097
1098 return;
1099 }
1100
1101
1102 /*----------------------------------------------------------------------------*/
1103 /*!
1104 * \brief OID handler for starting scheduled scan
1105 *
1106 * \param[in]
1107 *
1108 * \return none
1109 */
1110 /*----------------------------------------------------------------------------*/
1111 BOOLEAN
1112 scnFsmSchedScanRequest(IN P_ADAPTER_T prAdapter,
1113 IN UINT_8 ucSsidNum,
1114 IN P_PARAM_SSID_T prSsid,
1115 IN UINT_32 u4IeLength, IN PUINT_8 pucIe, IN UINT_16 u2Interval)
1116 {
1117 P_SCAN_INFO_T prScanInfo;
1118 P_NLO_PARAM_T prNloParam;
1119 P_SCAN_PARAM_T prScanParam;
1120 P_CMD_NLO_REQ prCmdNloReq;
1121 UINT_32 i, j;
1122
1123 ASSERT(prAdapter);
1124
1125 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1126 prNloParam = &prScanInfo->rNloParam;
1127 prScanParam = &prNloParam->rScanParam;
1128
1129 ASSERT(prScanInfo->fgNloScanning == FALSE);
1130
1131 /* 1. load parameters */
1132 prScanParam->ucSeqNum++;
1133 prScanParam->ucBssIndex = prAdapter->prAisBssInfo->ucBssIndex;
1134 prNloParam->fgStopAfterIndication = TRUE;
1135 prNloParam->ucFastScanIteration = 0;
1136 prNloParam->u2FastScanPeriod = u2Interval;
1137 prNloParam->u2SlowScanPeriod = u2Interval;
1138
1139 if (prScanParam->ucSSIDNum > CFG_SCAN_SSID_MAX_NUM) {
1140 prScanParam->ucSSIDNum = CFG_SCAN_SSID_MAX_NUM;
1141 } else {
1142 prScanParam->ucSSIDNum = ucSsidNum;
1143 }
1144
1145 if (prNloParam->ucMatchSSIDNum > CFG_SCAN_SSID_MATCH_MAX_NUM) {
1146 prNloParam->ucMatchSSIDNum = CFG_SCAN_SSID_MATCH_MAX_NUM;
1147 } else {
1148 prNloParam->ucMatchSSIDNum = ucSsidNum;
1149 }
1150
1151 for (i = 0; i < prNloParam->ucMatchSSIDNum; i++) {
1152 if (i < CFG_SCAN_SSID_MAX_NUM) {
1153 COPY_SSID(prScanParam->aucSpecifiedSSID[i],
1154 prScanParam->ucSpecifiedSSIDLen[i],
1155 prSsid[i].aucSsid, (UINT_8) prSsid[i].u4SsidLen);
1156 }
1157
1158 COPY_SSID(prNloParam->aucMatchSSID[i],
1159 prNloParam->ucMatchSSIDLen[i],
1160 prSsid[i].aucSsid, (UINT_8) prSsid[i].u4SsidLen);
1161
1162 prNloParam->aucCipherAlgo[i] = 0;
1163 prNloParam->au2AuthAlgo[i] = 0;
1164
1165 for (j = 0; j < SCN_NLO_NETWORK_CHANNEL_NUM; j++) {
1166 prNloParam->aucChannelHint[i][j] = 0;
1167 }
1168 }
1169
1170 /* 2. prepare command for sending */
1171 prCmdNloReq = (P_CMD_NLO_REQ) cnmMemAlloc(prAdapter,
1172 RAM_TYPE_BUF,
1173 sizeof(CMD_NLO_REQ) + prScanParam->u2IELen);
1174
1175 if (!prCmdNloReq) {
1176 ASSERT(0); /* Can't initiate NLO operation */
1177 return FALSE;
1178 }
1179
1180 /* 3. send command packet for NLO operation */
1181 kalMemZero(prCmdNloReq, sizeof(CMD_NLO_REQ));
1182
1183 prCmdNloReq->ucSeqNum = prScanParam->ucSeqNum;
1184 prCmdNloReq->ucBssIndex = prScanParam->ucBssIndex;
1185 prCmdNloReq->fgStopAfterIndication = prNloParam->fgStopAfterIndication;
1186 prCmdNloReq->ucFastScanIteration = prNloParam->ucFastScanIteration;
1187 prCmdNloReq->u2FastScanPeriod = prNloParam->u2FastScanPeriod;
1188 prCmdNloReq->u2SlowScanPeriod = prNloParam->u2SlowScanPeriod;
1189 prCmdNloReq->ucEntryNum = prNloParam->ucMatchSSIDNum;
1190 for (i = 0; i < prNloParam->ucMatchSSIDNum; i++) {
1191 COPY_SSID(prCmdNloReq->arNetworkList[i].aucSSID,
1192 prCmdNloReq->arNetworkList[i].ucSSIDLength,
1193 prNloParam->aucMatchSSID[i], prNloParam->ucMatchSSIDLen[i]);
1194
1195 prCmdNloReq->arNetworkList[i].ucCipherAlgo = prNloParam->aucCipherAlgo[i];
1196 prCmdNloReq->arNetworkList[i].u2AuthAlgo = prNloParam->au2AuthAlgo[i];
1197
1198 for (j = 0; j < SCN_NLO_NETWORK_CHANNEL_NUM; j++) {
1199 prCmdNloReq->arNetworkList[i].ucNumChannelHint[j] =
1200 prNloParam->aucChannelHint[i][j];
1201 }
1202 }
1203
1204 if (prScanParam->u2IELen <= MAX_IE_LENGTH) {
1205 prCmdNloReq->u2IELen = prScanParam->u2IELen;
1206 } else {
1207 prCmdNloReq->u2IELen = MAX_IE_LENGTH;
1208 }
1209
1210 if (prScanParam->u2IELen) {
1211 kalMemCopy(prCmdNloReq->aucIE,
1212 prScanParam->aucIE, sizeof(UINT_8) * prCmdNloReq->u2IELen);
1213 }
1214
1215 wlanSendSetQueryCmd(prAdapter,
1216 CMD_ID_SET_NLO_REQ,
1217 TRUE,
1218 FALSE,
1219 TRUE,
1220 nicCmdEventSetCommon,
1221 nicOidCmdTimeoutCommon,
1222 sizeof(CMD_NLO_REQ) + prCmdNloReq->u2IELen,
1223 (PUINT_8) prCmdNloReq, NULL, 0);
1224
1225 cnmMemFree(prAdapter, (PVOID) prCmdNloReq);
1226
1227 return TRUE;
1228 }
1229
1230
1231 /*----------------------------------------------------------------------------*/
1232 /*!
1233 * \brief OID handler for stopping scheduled scan
1234 *
1235 * \param[in]
1236 *
1237 * \return none
1238 */
1239 /*----------------------------------------------------------------------------*/
1240 BOOLEAN scnFsmSchedScanStopRequest(IN P_ADAPTER_T prAdapter)
1241 {
1242 P_SCAN_INFO_T prScanInfo;
1243 P_NLO_PARAM_T prNloParam;
1244 P_SCAN_PARAM_T prScanParam;
1245 CMD_NLO_CANCEL rCmdNloCancel;
1246
1247 ASSERT(prAdapter);
1248
1249 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1250 prNloParam = &prScanInfo->rNloParam;
1251 prScanParam = &prNloParam->rScanParam;
1252
1253 if (prScanInfo->fgNloScanning == TRUE) {
1254 /* send cancel message to firmware domain */
1255 rCmdNloCancel.ucSeqNum = prScanParam->ucSeqNum;
1256
1257 wlanSendSetQueryCmd(prAdapter,
1258 CMD_ID_SET_NLO_CANCEL,
1259 TRUE,
1260 FALSE,
1261 TRUE,
1262 nicCmdEventSetStopSchedScan,
1263 nicOidCmdTimeoutCommon,
1264 sizeof(CMD_NLO_CANCEL), (PUINT_8) &rCmdNloCancel, NULL, 0);
1265
1266 prScanInfo->fgNloScanning = FALSE;
1267
1268 return TRUE;
1269 } else {
1270 return FALSE;
1271 }
1272 }