2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_2/mgmt/scan_fsm.c#1 $
6 \brief This file defines the state transition function for SCAN FSM.
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 .
12 /*******************************************************************************
13 * Copyright (c) 2007 MediaTek Inc.
15 * All rights reserved. Copying, compilation, modification, distribution
16 * or any other use whatsoever of this material is strictly prohibited
17 * except in accordance with a Software License Agreement with
19 ********************************************************************************
22 /*******************************************************************************
25 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
26 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
27 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
28 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
29 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
30 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
31 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
32 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
33 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
34 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
35 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
36 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
37 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
39 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
40 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
41 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
42 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
43 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
45 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
46 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
47 * OF LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
48 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
49 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
51 ********************************************************************************
58 * [ALPS00096191] [MT6620 Wi-Fi][Driver][Firmware] Porting to ALPS4.0_DEV branch
59 * sync to up-to-date changes including:
64 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
65 * Adjust code for DBG and CONFIG_XLOG.
67 * 11 14 2011 yuche.tsai
68 * [WCXRP00001107] [Volunteer Patch][Driver] Large Network Type index assert in FW issue.
69 * Avoid possible FW assert when unload P2P module.
72 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
73 * modify the xlog related code.
76 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
77 * Add XLOG related code and define.
79 * 10 19 2011 yuche.tsai
80 * [WCXRP00001045] [WiFi Direct][Driver] Check 2.1 branch.
82 * Davinci Maintrunk Label: MT6620_WIFI_DRIVER_FW_TRUNK_MT6620E5_111019_0926.
85 * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
86 * sparse channel detection:
87 * driver: collect sparse channel information with scan-done event
91 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
92 * free mailbox message afte parsing is completed.
95 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
96 * 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
99 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
100 * Remove flag CFG_WIFI_DIRECT_MOVED.
103 * [WCXRP00000604] [MT6620 Wi-Fi][Driver] Surpress Klockwork Warning
104 * surpress klock warning with code path rewritten
107 * [WCXRP00000577] [MT6620 Wi-Fi][Driver][FW] Create V2.0 branch for firmware and driver
108 * create V2.0 driver release based on label "MT6620_WIFI_DRIVER_V2_0_110318_1600" from main trunk
110 * 03 18 2011 cm.chang
111 * [WCXRP00000576] [MT6620 Wi-Fi][Driver][FW] Remove P2P compile option in scan req/cancel command
114 * 02 18 2011 yuche.tsai
115 * [WCXRP00000478] [Volunteer Patch][MT6620][Driver] Probe request frame during search phase do not contain P2P wildcard SSID.
116 * Take P2P wildcard SSID into consideration.
118 * 01 27 2011 yuche.tsai
119 * [WCXRP00000399] [Volunteer Patch][MT6620/MT5931][Driver] Fix scan side effect after P2P module separate.
120 * Fix scan channel extension issue when p2p module is not registered.
122 * 01 26 2011 yuche.tsai
123 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
126 * 01 25 2011 yuche.tsai
127 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
128 * Fix Compile Error when DBG is disabled.
130 * 12 07 2010 cm.chang
131 * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
132 * 1. Country code is from NVRAM or supplicant
133 * 2. Change band definition in CMD/EVENT.
135 * 09 03 2010 kevin.huang
137 * Refine #include sequence and solve recursive/nested #include issue
141 * eliminate klockwork errors
145 * add interface for RLM to trigger OBSS-SCAN.
147 * 08 16 2010 yuche.tsai
149 * Fix bug for processing queued scan request.
151 * 08 11 2010 yuche.tsai
153 * Add a function for returning channel.
155 * 08 05 2010 yuche.tsai
157 * Update SCAN FSM for support P2P Device discovery scan.
161 * surpress compilation warning.
163 * 07 26 2010 yuche.tsai
165 * Add option of channel extension while cancelling scan request.
167 * 07 21 2010 yuche.tsai
169 * Add P2P Scan & Scan Result Parsing & Saving.
173 * pass band information for scan in an efficient way by mapping ENUM_BAND_T into UINT_8..
177 * due to FW/DRV won't be sync. precisely, some strict assertions should be eased.
181 * [WPD00003833] [MT6620 and MT5931] Driver migration.
182 * SCN module is now able to handle multiple concurrent scanning requests
186 * [WPD00003833] [MT6620 and MT5931] Driver migration.
187 * bugfix for SCN migration
188 * 1) modify QUEUE_CONCATENATE_QUEUES() so it could be used to concatence with an empty queue
189 * 2) before AIS issues scan request, network(BSS) needs to be activated first
190 * 3) only invoke COPY_SSID when using specified SSID for scan
194 * [WPD00003833] [MT6620 and MT5931] Driver migration.
195 * driver no longer generates probe request frames
199 * [WPD00003833] [MT6620 and MT5931] Driver migration.
200 * pass band with channel number information as scan parameter
204 * [WPD00003833] [MT6620 and MT5931] Driver migration.
205 * remove timer in DRV-SCN.
209 * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
210 * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
211 * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
215 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
218 * [WPD00003833][MT6620 and MT5931] Driver migration
219 * take use of RLM module for parsing/generating HT IEs for 11n capability
222 * [WPD00003833][MT6620 and MT5931] Driver migration
223 * when returning to SCAN_IDLE state, send a correct message to source FSM.
226 * [WPD00003833][MT6620 and MT5931] Driver migration
227 * implementation of DRV-SCN and related mailbox message handling.
230 * [WPD00003833][MT6620 and MT5931] Driver migration
231 * comment out RLM APIs by CFG_RLM_MIGRATION.
234 * [WPD00003833][MT6620 and MT5931] Driver migration
235 * add scan_fsm into building.
237 * 05 14 2010 kevin.huang
238 * [BORA00000794][WIFISYS][New Feature]Power Management Support
239 * Refine the order of Stop TX Queue and Switch Channel
241 * 05 12 2010 kevin.huang
242 * [BORA00000794][WIFISYS][New Feature]Power Management Support
243 * Update pause/resume/flush API to new Bitmap API
245 * 05 12 2010 kevin.huang
246 * [BORA00000794][WIFISYS][New Feature]Power Management Support
247 * Add Power Management - Legacy PS-POLL support.
249 * 03 18 2010 kevin.huang
250 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
251 * Ignore the PROBE_DELAY state if the value of Probe Delay == 0
253 * 03 10 2010 kevin.huang
254 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
255 * Add Channel Manager for arbitration of JOIN and SCAN Req
257 * 02 23 2010 kevin.huang
258 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
259 * Add support scan channel 1~14 and update scan result's frequency infou1rwduu`wvpghlqg|n`slk+mpdkb
261 * 01 08 2010 kevin.huang
262 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
263 * Add set RX Filter to receive BCN from different BSSID during SCAN
265 * 12 18 2009 cm.chang
266 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
269 * Nov 25 2009 mtk01461
270 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
271 * Remove flag of CFG_TEST_MGMT_FSM
273 * Nov 20 2009 mtk01461
274 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
275 * Change parameter of scanSendProbeReqFrames()
277 * Nov 16 2009 mtk01461
278 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
279 * Update scnFsmSteps()
281 * Nov 5 2009 mtk01461
282 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
285 * Nov 5 2009 mtk01461
286 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
290 /*******************************************************************************
291 * C O M P I L E R F L A G S
292 ********************************************************************************
295 /*******************************************************************************
296 * E X T E R N A L R E F E R E N C E S
297 ********************************************************************************
301 /*******************************************************************************
303 ********************************************************************************
306 /*******************************************************************************
308 ********************************************************************************
311 /*******************************************************************************
312 * P U B L I C D A T A
313 ********************************************************************************
316 /*******************************************************************************
317 * P R I V A T E D A T A
318 ********************************************************************************
321 /*lint -save -e64 Type mismatch */
322 static PUINT_8 apucDebugScanState[SCAN_STATE_NUM] = {
323 (PUINT_8)DISP_STRING("SCAN_STATE_IDLE"),
324 (PUINT_8)DISP_STRING("SCAN_STATE_SCANNING"),
329 /*******************************************************************************
331 ********************************************************************************
334 /*******************************************************************************
335 * F U N C T I O N D E C L A R A T I O N S
336 ********************************************************************************
339 /*******************************************************************************
341 ********************************************************************************
343 /*----------------------------------------------------------------------------*/
351 /*----------------------------------------------------------------------------*/
354 IN P_ADAPTER_T prAdapter,
355 IN ENUM_SCAN_STATE_T eNextState
358 P_SCAN_INFO_T prScanInfo;
359 P_SCAN_PARAM_T prScanParam;
360 P_MSG_HDR_T prMsgHdr;
362 BOOLEAN fgIsTransition = (BOOLEAN)FALSE;
364 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
365 prScanParam = &prScanInfo->rScanParam;
370 DBGLOG(SCN, STATE, ("[%d] TRANSITION: [%d] -> [%d]\n",
372 prScanInfo->eCurrentState,
375 DBGLOG(SCN, STATE, ("TRANSITION: [%s] -> [%s]\n",
376 apucDebugScanState[prScanInfo->eCurrentState],
377 apucDebugScanState[eNextState]));
380 /* NOTE(Kevin): This is the only place to change the eCurrentState(except initial) */
381 prScanInfo->eCurrentState = eNextState;
383 fgIsTransition = (BOOLEAN)FALSE;
385 switch (prScanInfo->eCurrentState) {
386 case SCAN_STATE_IDLE:
387 /* check for pending scanning requests */
388 if(!LINK_IS_EMPTY(&(prScanInfo->rPendingMsgList))) {
389 // load next message from pending list as scan parameters
390 LINK_REMOVE_HEAD(&(prScanInfo->rPendingMsgList), prMsgHdr, P_MSG_HDR_T);
392 if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
393 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
394 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
395 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
396 scnFsmHandleScanMsg(prAdapter, (P_MSG_SCN_SCAN_REQ)prMsgHdr);
399 scnFsmHandleScanMsgV2(prAdapter, (P_MSG_SCN_SCAN_REQ_V2)prMsgHdr);
402 /* switch to next state */
403 eNextState = SCAN_STATE_SCANNING;
404 fgIsTransition = TRUE;
406 cnmMemFree(prAdapter, prMsgHdr);
410 case SCAN_STATE_SCANNING:
411 if(prScanParam->fgIsScanV2 == FALSE) {
412 scnSendScanReq(prAdapter);
415 scnSendScanReqV2(prAdapter);
425 while (fgIsTransition);
431 /*----------------------------------------------------------------------------*/
433 * \brief Generate CMD_ID_SCAN_REQ command
439 /*----------------------------------------------------------------------------*/
442 IN P_ADAPTER_T prAdapter
445 P_SCAN_INFO_T prScanInfo;
446 P_SCAN_PARAM_T prScanParam;
447 CMD_SCAN_REQ rCmdScanReq;
452 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
453 prScanParam = &prScanInfo->rScanParam;
455 // send command packet for scan
456 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ));
458 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
459 rCmdScanReq.ucNetworkType = (UINT_8)prScanParam->eNetTypeIndex;
460 rCmdScanReq.ucScanType = (UINT_8)prScanParam->eScanType;
461 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
463 if(prScanParam->ucSSIDNum == 1) {
464 COPY_SSID(rCmdScanReq.aucSSID,
465 rCmdScanReq.ucSSIDLength,
466 prScanParam->aucSpecifiedSSID[0],
467 prScanParam->ucSpecifiedSSIDLen[0]);
470 rCmdScanReq.ucChannelType = (UINT_8)prScanParam->eScanChannel;
472 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
474 * 1. Specified Listen Channel of passive scan for LISTEN state.
475 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
477 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
479 for(i = 0 ; i < rCmdScanReq.ucChannelListNum ; i++) {
480 rCmdScanReq.arChannelList[i].ucBand =
481 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
483 rCmdScanReq.arChannelList[i].ucChannelNum =
484 (UINT_8)prScanParam->arChnlInfoList[i].ucChannelNum;
488 #if CFG_ENABLE_WIFI_DIRECT
489 if(prAdapter->fgIsP2PRegistered) {
490 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2PassiveListenInterval;
494 if(prScanParam->u2IELen <= MAX_IE_LENGTH) {
495 rCmdScanReq.u2IELen = prScanParam->u2IELen;
498 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
501 if (prScanParam->u2IELen) {
502 kalMemCopy(rCmdScanReq.aucIE,
504 sizeof(UINT_8) * rCmdScanReq.u2IELen);
507 wlanSendSetQueryCmd(prAdapter,
514 OFFSET_OF(CMD_SCAN_REQ, aucIE) + rCmdScanReq.u2IELen,
515 (PUINT_8)&rCmdScanReq,
521 /*----------------------------------------------------------------------------*/
523 * \brief Generate CMD_ID_SCAN_REQ_V2 command
529 /*----------------------------------------------------------------------------*/
532 IN P_ADAPTER_T prAdapter
535 P_SCAN_INFO_T prScanInfo;
536 P_SCAN_PARAM_T prScanParam;
537 CMD_SCAN_REQ_V2 rCmdScanReq;
542 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
543 prScanParam = &prScanInfo->rScanParam;
545 // send command packet for scan
546 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ_V2));
548 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
549 rCmdScanReq.ucNetworkType = (UINT_8)prScanParam->eNetTypeIndex;
550 rCmdScanReq.ucScanType = (UINT_8)prScanParam->eScanType;
551 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
553 for (i = 0 ; i < prScanParam->ucSSIDNum; i++) {
554 COPY_SSID(rCmdScanReq.arSSID[i].aucSsid,
555 rCmdScanReq.arSSID[i].u4SsidLen,
556 prScanParam->aucSpecifiedSSID[i],
557 prScanParam->ucSpecifiedSSIDLen[i]);
560 rCmdScanReq.u2ProbeDelayTime = (UINT_8)prScanParam->u2ProbeDelayTime;
561 rCmdScanReq.ucChannelType = (UINT_8)prScanParam->eScanChannel;
563 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
565 * 1. Specified Listen Channel of passive scan for LISTEN state.
566 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
568 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
570 for(i = 0 ; i < rCmdScanReq.ucChannelListNum ; i++) {
571 rCmdScanReq.arChannelList[i].ucBand =
572 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
574 rCmdScanReq.arChannelList[i].ucChannelNum =
575 (UINT_8)prScanParam->arChnlInfoList[i].ucChannelNum;
579 #if CFG_ENABLE_WIFI_DIRECT
580 if(prAdapter->fgIsP2PRegistered) {
581 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2PassiveListenInterval;
585 if(prScanParam->u2IELen <= MAX_IE_LENGTH) {
586 rCmdScanReq.u2IELen = prScanParam->u2IELen;
589 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
592 if (prScanParam->u2IELen) {
593 kalMemCopy(rCmdScanReq.aucIE,
595 sizeof(UINT_8) * rCmdScanReq.u2IELen);
598 wlanSendSetQueryCmd(prAdapter,
605 OFFSET_OF(CMD_SCAN_REQ_V2, aucIE) + rCmdScanReq.u2IELen,
606 (PUINT_8)&rCmdScanReq,
613 /*----------------------------------------------------------------------------*/
621 /*----------------------------------------------------------------------------*/
624 IN P_ADAPTER_T prAdapter,
625 IN P_MSG_HDR_T prMsgHdr
628 P_SCAN_INFO_T prScanInfo;
629 P_SCAN_PARAM_T prScanParam;
633 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
634 prScanParam = &prScanInfo->rScanParam;
637 if (prScanInfo->eCurrentState == SCAN_STATE_IDLE) {
638 if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
639 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
640 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
641 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
642 scnFsmHandleScanMsg(prAdapter, (P_MSG_SCN_SCAN_REQ)prMsgHdr);
644 else if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
645 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
646 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
647 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
648 scnFsmHandleScanMsgV2(prAdapter, (P_MSG_SCN_SCAN_REQ_V2)prMsgHdr);
651 // should not deliver to this function
655 cnmMemFree(prAdapter, prMsgHdr);
656 scnFsmSteps(prAdapter, SCAN_STATE_SCANNING);
659 LINK_INSERT_TAIL(&prScanInfo->rPendingMsgList, &prMsgHdr->rLinkEntry);
667 /*----------------------------------------------------------------------------*/
675 /*----------------------------------------------------------------------------*/
678 IN P_ADAPTER_T prAdapter,
679 IN P_MSG_HDR_T prMsgHdr
682 P_MSG_SCN_SCAN_CANCEL prScanCancel;
683 P_SCAN_INFO_T prScanInfo;
684 P_SCAN_PARAM_T prScanParam;
685 CMD_SCAN_CANCEL rCmdScanCancel;
689 prScanCancel = (P_MSG_SCN_SCAN_CANCEL)prMsgHdr;
690 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
691 prScanParam = &prScanInfo->rScanParam;
693 if (prScanInfo->eCurrentState != SCAN_STATE_IDLE) {
694 if(prScanCancel->ucSeqNum == prScanParam->ucSeqNum &&
695 prScanCancel->ucNetTypeIndex == (UINT_8)prScanParam->eNetTypeIndex) {
696 /* send cancel message to firmware domain */
697 rCmdScanCancel.ucSeqNum = prScanParam->ucSeqNum;
699 #if CFG_ENABLE_WIFI_DIRECT
700 if(prAdapter->fgIsP2PRegistered) {
701 rCmdScanCancel.ucIsExtChannel = (UINT_8) prScanCancel->fgIsChannelExt;
704 rCmdScanCancel.ucIsExtChannel = (UINT_8) FALSE;
708 wlanSendSetQueryCmd(prAdapter,
715 sizeof(CMD_SCAN_CANCEL),
716 (PUINT_8)&rCmdScanCancel,
720 /* generate scan-done event for caller */
721 scnFsmGenerateScanDoneMsg(prAdapter,
722 prScanParam->ucSeqNum,
723 (UINT_8)prScanParam->eNetTypeIndex,
724 SCAN_STATUS_CANCELLED);
726 /* switch to next pending scan */
727 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
730 scnFsmRemovePendingMsg(prAdapter, prScanCancel->ucSeqNum, prScanCancel->ucNetTypeIndex);
734 cnmMemFree(prAdapter, prMsgHdr);
740 /*----------------------------------------------------------------------------*/
742 * \brief Scan Message Parsing (Legacy)
748 /*----------------------------------------------------------------------------*/
750 scnFsmHandleScanMsg (
751 IN P_ADAPTER_T prAdapter,
752 IN P_MSG_SCN_SCAN_REQ prScanReqMsg
755 P_SCAN_INFO_T prScanInfo;
756 P_SCAN_PARAM_T prScanParam;
760 ASSERT(prScanReqMsg);
762 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
763 prScanParam = &prScanInfo->rScanParam;
765 prScanParam->eScanType = prScanReqMsg->eScanType;
766 prScanParam->eNetTypeIndex = (ENUM_NETWORK_TYPE_INDEX_T)prScanReqMsg->ucNetTypeIndex;
767 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
768 if (prScanParam->ucSSIDType & (SCAN_REQ_SSID_SPECIFIED | SCAN_REQ_SSID_P2P_WILDCARD)) {
769 prScanParam->ucSSIDNum = 1;
771 COPY_SSID(prScanParam->aucSpecifiedSSID[0],
772 prScanParam->ucSpecifiedSSIDLen[0],
773 prScanReqMsg->aucSSID,
774 prScanReqMsg->ucSSIDLength);
776 // reset SSID length to zero for rest array entries
777 for(i = 1 ; i < SCN_SSID_MAX_NUM ; i++) {
778 prScanParam->ucSpecifiedSSIDLen[i] = 0;
782 prScanParam->ucSSIDNum = 0;
784 for(i = 0 ; i < SCN_SSID_MAX_NUM ; i++) {
785 prScanParam->ucSpecifiedSSIDLen[i] = 0;
789 prScanParam->u2ProbeDelayTime = 0;
790 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
791 if(prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
792 if(prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
793 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
796 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
799 kalMemCopy(prScanParam->arChnlInfoList,
800 prScanReqMsg->arChnlInfoList,
801 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
804 if(prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
805 prScanParam->u2IELen = prScanReqMsg->u2IELen;
808 prScanParam->u2IELen = MAX_IE_LENGTH;
811 if(prScanParam->u2IELen) {
812 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
815 #if CFG_ENABLE_WIFI_DIRECT
816 if(prAdapter->fgIsP2PRegistered) {
817 prScanParam->u2PassiveListenInterval = prScanReqMsg->u2ChannelDwellTime;
820 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
822 if(prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
823 prScanParam->fgIsObssScan = TRUE;
826 prScanParam->fgIsObssScan = FALSE;
829 prScanParam->fgIsScanV2 = FALSE;
835 /*----------------------------------------------------------------------------*/
837 * \brief Scan Message Parsing - V2 with multiple SSID support
843 /*----------------------------------------------------------------------------*/
845 scnFsmHandleScanMsgV2 (
846 IN P_ADAPTER_T prAdapter,
847 IN P_MSG_SCN_SCAN_REQ_V2 prScanReqMsg
850 P_SCAN_INFO_T prScanInfo;
851 P_SCAN_PARAM_T prScanParam;
855 ASSERT(prScanReqMsg);
856 ASSERT(prScanReqMsg->ucSSIDNum <= SCN_SSID_MAX_NUM);
858 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
859 prScanParam = &prScanInfo->rScanParam;
861 prScanParam->eScanType = prScanReqMsg->eScanType;
862 prScanParam->eNetTypeIndex = (ENUM_NETWORK_TYPE_INDEX_T)prScanReqMsg->ucNetTypeIndex;
863 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
864 prScanParam->ucSSIDNum = prScanReqMsg->ucSSIDNum;
866 for(i = 0 ; i < prScanReqMsg->ucSSIDNum ; i++) {
867 COPY_SSID(prScanParam->aucSpecifiedSSID[i],
868 prScanParam->ucSpecifiedSSIDLen[i],
869 prScanReqMsg->prSsid[i].aucSsid,
870 (UINT_8)prScanReqMsg->prSsid[i].u4SsidLen);
873 prScanParam->u2ProbeDelayTime = prScanReqMsg->u2ProbeDelay;
874 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
875 if(prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
876 if(prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
877 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
880 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
883 kalMemCopy(prScanParam->arChnlInfoList,
884 prScanReqMsg->arChnlInfoList,
885 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
888 if(prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
889 prScanParam->u2IELen = prScanReqMsg->u2IELen;
892 prScanParam->u2IELen = MAX_IE_LENGTH;
895 if(prScanParam->u2IELen) {
896 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
899 #if CFG_ENABLE_WIFI_DIRECT
900 if(prAdapter->fgIsP2PRegistered) {
901 prScanParam->u2PassiveListenInterval = prScanReqMsg->u2ChannelDwellTime;
904 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
906 if(prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
907 prScanParam->fgIsObssScan = TRUE;
910 prScanParam->fgIsObssScan = FALSE;
913 prScanParam->fgIsScanV2 = TRUE;
919 /*----------------------------------------------------------------------------*/
921 * \brief Remove pending scan request
927 /*----------------------------------------------------------------------------*/
929 scnFsmRemovePendingMsg (
930 IN P_ADAPTER_T prAdapter,
932 IN UINT_8 ucNetTypeIndex
935 P_SCAN_INFO_T prScanInfo;
936 P_SCAN_PARAM_T prScanParam;
937 P_MSG_HDR_T prPendingMsgHdr, prPendingMsgHdrNext, prRemoveMsgHdr = NULL;
938 P_LINK_ENTRY_T prRemoveLinkEntry = NULL;
942 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
943 prScanParam = &prScanInfo->rScanParam;
945 /* traverse through rPendingMsgList for removal */
946 LINK_FOR_EACH_ENTRY_SAFE(prPendingMsgHdr,
948 &(prScanInfo->rPendingMsgList),
951 if(prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
952 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
953 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
954 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
955 P_MSG_SCN_SCAN_REQ prScanReqMsg = (P_MSG_SCN_SCAN_REQ)prPendingMsgHdr;
957 if(ucSeqNum == prScanReqMsg->ucSeqNum &&
958 ucNetTypeIndex == prScanReqMsg->ucNetTypeIndex) {
959 prRemoveLinkEntry = &(prScanReqMsg->rMsgHdr.rLinkEntry);
960 prRemoveMsgHdr = prPendingMsgHdr;
963 else if(prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
964 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
965 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
966 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
967 P_MSG_SCN_SCAN_REQ_V2 prScanReqMsgV2 = (P_MSG_SCN_SCAN_REQ_V2)prPendingMsgHdr;
969 if(ucSeqNum == prScanReqMsgV2->ucSeqNum &&
970 ucNetTypeIndex == prScanReqMsgV2->ucNetTypeIndex) {
971 prRemoveLinkEntry = &(prScanReqMsgV2->rMsgHdr.rLinkEntry);
972 prRemoveMsgHdr = prPendingMsgHdr;
976 if(prRemoveLinkEntry) {
977 /* generate scan-done event for caller */
978 scnFsmGenerateScanDoneMsg(prAdapter,
981 SCAN_STATUS_CANCELLED);
983 /* remove from pending list */
984 LINK_REMOVE_KNOWN_ENTRY(&(prScanInfo->rPendingMsgList), prRemoveLinkEntry);
985 cnmMemFree(prAdapter, prRemoveMsgHdr);
995 /*----------------------------------------------------------------------------*/
1003 /*----------------------------------------------------------------------------*/
1006 IN P_ADAPTER_T prAdapter,
1007 IN P_EVENT_SCAN_DONE prScanDone
1010 P_SCAN_INFO_T prScanInfo;
1011 P_SCAN_PARAM_T prScanParam;
1013 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1014 prScanParam = &prScanInfo->rScanParam;
1016 // buffer empty channel information
1017 if(prScanParam->eScanChannel == SCAN_CHANNEL_FULL
1018 || prScanParam->eScanChannel == SCAN_CHANNEL_2G4) {
1019 if(prScanDone->ucSparseChannelValid) {
1020 prScanInfo->fgIsSparseChannelValid = TRUE;
1021 prScanInfo->rSparseChannel.eBand = (ENUM_BAND_T)prScanDone->rSparseChannel.ucBand;
1022 prScanInfo->rSparseChannel.ucChannelNum = prScanDone->rSparseChannel.ucChannelNum;
1025 prScanInfo->fgIsSparseChannelValid = FALSE;
1029 if(prScanInfo->eCurrentState == SCAN_STATE_SCANNING &&
1030 prScanDone->ucSeqNum == prScanParam->ucSeqNum) {
1031 /* generate scan-done event for caller */
1032 scnFsmGenerateScanDoneMsg(prAdapter,
1033 prScanParam->ucSeqNum,
1034 (UINT_8)prScanParam->eNetTypeIndex,
1037 /* switch to next pending scan */
1038 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
1041 DBGLOG(SCN, LOUD, ("Unexpected SCAN-DONE event: SeqNum = %d, Current State = %d\n",
1042 prScanDone->ucSeqNum,
1043 prScanInfo->eCurrentState));
1047 } /* end of scnEventScanDone */
1050 /*----------------------------------------------------------------------------*/
1058 /*----------------------------------------------------------------------------*/
1060 scnFsmGenerateScanDoneMsg (
1061 IN P_ADAPTER_T prAdapter,
1063 IN UINT_8 ucNetTypeIndex,
1064 IN ENUM_SCAN_STATUS eScanStatus
1067 P_SCAN_INFO_T prScanInfo;
1068 P_SCAN_PARAM_T prScanParam;
1069 P_MSG_SCN_SCAN_DONE prScanDoneMsg;
1073 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1074 prScanParam = &prScanInfo->rScanParam;
1076 prScanDoneMsg = (P_MSG_SCN_SCAN_DONE)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_DONE));
1077 if (!prScanDoneMsg) {
1078 ASSERT(0); // Can't indicate SCAN FSM Complete
1082 if(prScanParam->fgIsObssScan == TRUE) {
1083 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_RLM_SCAN_DONE;
1086 switch((ENUM_NETWORK_TYPE_INDEX_T)ucNetTypeIndex) {
1087 case NETWORK_TYPE_AIS_INDEX:
1088 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_AIS_SCAN_DONE;
1091 #if CFG_ENABLE_WIFI_DIRECT
1092 case NETWORK_TYPE_P2P_INDEX:
1093 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_P2P_SCAN_DONE;
1097 #if CFG_ENABLE_BT_OVER_WIFI
1098 case NETWORK_TYPE_BOW_INDEX:
1099 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_BOW_SCAN_DONE;
1104 DBGLOG(SCN, LOUD, ("Unexpected Network Type: %d\n", ucNetTypeIndex));
1110 prScanDoneMsg->ucSeqNum = ucSeqNum;
1111 prScanDoneMsg->ucNetTypeIndex = ucNetTypeIndex;
1112 prScanDoneMsg->eScanStatus = eScanStatus;
1114 mboxSendMsg(prAdapter,
1116 (P_MSG_HDR_T) prScanDoneMsg,
1117 MSG_SEND_METHOD_BUF);
1119 } /* end of scnFsmGenerateScanDoneMsg() */
1122 /*----------------------------------------------------------------------------*/
1124 * \brief Query for most sparse channel
1130 /*----------------------------------------------------------------------------*/
1132 scnQuerySparseChannel (
1133 IN P_ADAPTER_T prAdapter,
1134 P_ENUM_BAND_T prSparseBand,
1135 PUINT_8 pucSparseChannel
1138 P_SCAN_INFO_T prScanInfo;
1142 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1144 if(prScanInfo->fgIsSparseChannelValid == TRUE) {
1146 *prSparseBand = prScanInfo->rSparseChannel.eBand;
1149 if(pucSparseChannel) {
1150 *pucSparseChannel = prScanInfo->rSparseChannel.ucChannelNum;