2 ** $Id: //Department/DaVinci/BRANCHES/MT662X_593X_WIFI_DRIVER_V2_3/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 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
59 ** do not use fgIsP2PRegistered for checking but use network index
61 * 06 13 2012 yuche.tsai
63 * Update maintrunk driver.
64 * Add support for driver compose assoc request frame.
67 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
68 * Adjust code for DBG and CONFIG_XLOG.
70 * 11 14 2011 yuche.tsai
71 * [WCXRP00001095] [Volunteer Patch][Driver] Always Scan before enable Hot-Spot.
72 * Fix bug when unregister P2P network..
75 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
76 * modify the xlog related code.
79 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
80 * adding the code for XLOG.
83 * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
84 * sparse channel detection:
85 * driver: collect sparse channel information with scan-done event
89 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
90 * free mailbox message afte parsing is completed.
93 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
94 * 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
97 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
98 * Remove flag CFG_WIFI_DIRECT_MOVED.
101 * [WCXRP00000604] [MT6620 Wi-Fi][Driver] Surpress Klockwork Warning
102 * surpress klock warning with code path rewritten
104 * 03 18 2011 cm.chang
105 * [WCXRP00000576] [MT6620 Wi-Fi][Driver][FW] Remove P2P compile option in scan req/cancel command
108 * 02 18 2011 yuche.tsai
109 * [WCXRP00000478] [Volunteer Patch][MT6620][Driver] Probe request frame during search phase do not contain P2P wildcard SSID.
110 * Take P2P wildcard SSID into consideration.
112 * 01 27 2011 yuche.tsai
113 * [WCXRP00000399] [Volunteer Patch][MT6620/MT5931][Driver] Fix scan side effect after P2P module separate.
114 * Fix scan channel extension issue when p2p module is not registered.
116 * 01 26 2011 yuche.tsai
117 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
120 * 01 25 2011 yuche.tsai
121 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
122 * Fix Compile Error when DBG is disabled.
124 * 12 07 2010 cm.chang
125 * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
126 * 1. Country code is from NVRAM or supplicant
127 * 2. Change band definition in CMD/EVENT.
129 * 09 03 2010 kevin.huang
131 * Refine #include sequence and solve recursive/nested #include issue
135 * eliminate klockwork errors
139 * add interface for RLM to trigger OBSS-SCAN.
141 * 08 16 2010 yuche.tsai
143 * Fix bug for processing queued scan request.
145 * 08 11 2010 yuche.tsai
147 * Add a function for returning channel.
149 * 08 05 2010 yuche.tsai
151 * Update SCAN FSM for support P2P Device discovery scan.
155 * surpress compilation warning.
157 * 07 26 2010 yuche.tsai
159 * Add option of channel extension while cancelling scan request.
161 * 07 21 2010 yuche.tsai
163 * Add P2P Scan & Scan Result Parsing & Saving.
167 * pass band information for scan in an efficient way by mapping ENUM_BAND_T into UINT_8..
171 * due to FW/DRV won't be sync. precisely, some strict assertions should be eased.
175 * [WPD00003833] [MT6620 and MT5931] Driver migration.
176 * SCN module is now able to handle multiple concurrent scanning requests
180 * [WPD00003833] [MT6620 and MT5931] Driver migration.
181 * bugfix for SCN migration
182 * 1) modify QUEUE_CONCATENATE_QUEUES() so it could be used to concatence with an empty queue
183 * 2) before AIS issues scan request, network(BSS) needs to be activated first
184 * 3) only invoke COPY_SSID when using specified SSID for scan
188 * [WPD00003833] [MT6620 and MT5931] Driver migration.
189 * driver no longer generates probe request frames
193 * [WPD00003833] [MT6620 and MT5931] Driver migration.
194 * pass band with channel number information as scan parameter
198 * [WPD00003833] [MT6620 and MT5931] Driver migration.
199 * remove timer in DRV-SCN.
203 * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
204 * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
205 * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
209 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
212 * [WPD00003833][MT6620 and MT5931] Driver migration
213 * take use of RLM module for parsing/generating HT IEs for 11n capability
216 * [WPD00003833][MT6620 and MT5931] Driver migration
217 * when returning to SCAN_IDLE state, send a correct message to source FSM.
220 * [WPD00003833][MT6620 and MT5931] Driver migration
221 * implementation of DRV-SCN and related mailbox message handling.
224 * [WPD00003833][MT6620 and MT5931] Driver migration
225 * comment out RLM APIs by CFG_RLM_MIGRATION.
228 * [WPD00003833][MT6620 and MT5931] Driver migration
229 * add scan_fsm into building.
231 * 05 14 2010 kevin.huang
232 * [BORA00000794][WIFISYS][New Feature]Power Management Support
233 * Refine the order of Stop TX Queue and Switch Channel
235 * 05 12 2010 kevin.huang
236 * [BORA00000794][WIFISYS][New Feature]Power Management Support
237 * Update pause/resume/flush API to new Bitmap API
239 * 05 12 2010 kevin.huang
240 * [BORA00000794][WIFISYS][New Feature]Power Management Support
241 * Add Power Management - Legacy PS-POLL support.
243 * 03 18 2010 kevin.huang
244 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
245 * Ignore the PROBE_DELAY state if the value of Probe Delay == 0
247 * 03 10 2010 kevin.huang
248 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
249 * Add Channel Manager for arbitration of JOIN and SCAN Req
251 * 02 23 2010 kevin.huang
252 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
253 * Add support scan channel 1~14 and update scan result's frequency infou1rwduu`wvpghlqg|n`slk+mpdkb
255 * 01 08 2010 kevin.huang
256 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
257 * Add set RX Filter to receive BCN from different BSSID during SCAN
259 * 12 18 2009 cm.chang
260 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
263 * Nov 25 2009 mtk01461
264 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
265 * Remove flag of CFG_TEST_MGMT_FSM
267 * Nov 20 2009 mtk01461
268 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
269 * Change parameter of scanSendProbeReqFrames()
271 * Nov 16 2009 mtk01461
272 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
273 * Update scnFsmSteps()
275 * Nov 5 2009 mtk01461
276 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
279 * Nov 5 2009 mtk01461
280 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
284 /*******************************************************************************
285 * C O M P I L E R F L A G S
286 ********************************************************************************
289 /*******************************************************************************
290 * E X T E R N A L R E F E R E N C E S
291 ********************************************************************************
295 /*******************************************************************************
297 ********************************************************************************
300 /*******************************************************************************
302 ********************************************************************************
305 /*******************************************************************************
306 * P U B L I C D A T A
307 ********************************************************************************
310 /*******************************************************************************
311 * P R I V A T E D A T A
312 ********************************************************************************
315 /*lint -save -e64 Type mismatch */
316 static PUINT_8 apucDebugScanState[SCAN_STATE_NUM] = {
317 (PUINT_8)DISP_STRING("SCAN_STATE_IDLE"),
318 (PUINT_8)DISP_STRING("SCAN_STATE_SCANNING"),
323 /*******************************************************************************
325 ********************************************************************************
328 /*******************************************************************************
329 * F U N C T I O N D E C L A R A T I O N S
330 ********************************************************************************
333 /*******************************************************************************
335 ********************************************************************************
337 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
348 IN P_ADAPTER_T prAdapter,
349 IN ENUM_SCAN_STATE_T eNextState
352 P_SCAN_INFO_T prScanInfo;
353 P_SCAN_PARAM_T prScanParam;
354 P_MSG_HDR_T prMsgHdr;
356 BOOLEAN fgIsTransition = (BOOLEAN)FALSE;
358 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
359 prScanParam = &prScanInfo->rScanParam;
364 DBGLOG(SCN, STATE, ("TRANSITION: [%s] -> [%s]\n",
365 apucDebugScanState[prScanInfo->eCurrentState],
366 apucDebugScanState[eNextState]));
368 DBGLOG(SCN, STATE, ("[%d] TRANSITION: [%d] -> [%d]\n",
370 prScanInfo->eCurrentState,
374 /* NOTE(Kevin): This is the only place to change the eCurrentState(except initial) */
375 prScanInfo->eCurrentState = eNextState;
377 fgIsTransition = (BOOLEAN)FALSE;
379 switch (prScanInfo->eCurrentState) {
380 case SCAN_STATE_IDLE:
381 /* check for pending scanning requests */
382 if(!LINK_IS_EMPTY(&(prScanInfo->rPendingMsgList))) {
383 // load next message from pending list as scan parameters
384 LINK_REMOVE_HEAD(&(prScanInfo->rPendingMsgList), prMsgHdr, P_MSG_HDR_T);
386 if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
387 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
388 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
389 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
390 scnFsmHandleScanMsg(prAdapter, (P_MSG_SCN_SCAN_REQ)prMsgHdr);
393 scnFsmHandleScanMsgV2(prAdapter, (P_MSG_SCN_SCAN_REQ_V2)prMsgHdr);
396 /* switch to next state */
397 eNextState = SCAN_STATE_SCANNING;
398 fgIsTransition = TRUE;
400 cnmMemFree(prAdapter, prMsgHdr);
404 case SCAN_STATE_SCANNING:
405 if(prScanParam->fgIsScanV2 == FALSE) {
406 scnSendScanReq(prAdapter);
409 scnSendScanReqV2(prAdapter);
419 while (fgIsTransition);
425 /*----------------------------------------------------------------------------*/
427 * \brief Generate CMD_ID_SCAN_REQ command
433 /*----------------------------------------------------------------------------*/
436 IN P_ADAPTER_T prAdapter
439 P_SCAN_INFO_T prScanInfo;
440 P_SCAN_PARAM_T prScanParam;
441 CMD_SCAN_REQ rCmdScanReq;
446 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
447 prScanParam = &prScanInfo->rScanParam;
449 // send command packet for scan
450 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ));
452 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
453 rCmdScanReq.ucNetworkType = (UINT_8)prScanParam->eNetTypeIndex;
454 rCmdScanReq.ucScanType = (UINT_8)prScanParam->eScanType;
455 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
457 if(prScanParam->ucSSIDNum == 1) {
458 COPY_SSID(rCmdScanReq.aucSSID,
459 rCmdScanReq.ucSSIDLength,
460 prScanParam->aucSpecifiedSSID[0],
461 prScanParam->ucSpecifiedSSIDLen[0]);
464 rCmdScanReq.ucChannelType = (UINT_8)prScanParam->eScanChannel;
466 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
468 * 1. Specified Listen Channel of passive scan for LISTEN state.
469 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
471 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
473 for(i = 0 ; i < rCmdScanReq.ucChannelListNum ; i++) {
474 rCmdScanReq.arChannelList[i].ucBand =
475 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
477 rCmdScanReq.arChannelList[i].ucChannelNum =
478 (UINT_8)prScanParam->arChnlInfoList[i].ucChannelNum;
482 #if CFG_ENABLE_WIFI_DIRECT
483 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
484 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2PassiveListenInterval;
488 if(prScanParam->u2IELen <= MAX_IE_LENGTH) {
489 rCmdScanReq.u2IELen = prScanParam->u2IELen;
492 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
495 if (prScanParam->u2IELen) {
496 kalMemCopy(rCmdScanReq.aucIE,
498 sizeof(UINT_8) * rCmdScanReq.u2IELen);
501 wlanSendSetQueryCmd(prAdapter,
508 OFFSET_OF(CMD_SCAN_REQ, aucIE) + rCmdScanReq.u2IELen,
509 (PUINT_8)&rCmdScanReq,
515 /*----------------------------------------------------------------------------*/
517 * \brief Generate CMD_ID_SCAN_REQ_V2 command
523 /*----------------------------------------------------------------------------*/
526 IN P_ADAPTER_T prAdapter
529 P_SCAN_INFO_T prScanInfo;
530 P_SCAN_PARAM_T prScanParam;
531 CMD_SCAN_REQ_V2 rCmdScanReq;
536 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
537 prScanParam = &prScanInfo->rScanParam;
539 // send command packet for scan
540 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ_V2));
542 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
543 rCmdScanReq.ucNetworkType = (UINT_8)prScanParam->eNetTypeIndex;
544 rCmdScanReq.ucScanType = (UINT_8)prScanParam->eScanType;
545 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
547 for (i = 0 ; i < prScanParam->ucSSIDNum; i++) {
548 COPY_SSID(rCmdScanReq.arSSID[i].aucSsid,
549 rCmdScanReq.arSSID[i].u4SsidLen,
550 prScanParam->aucSpecifiedSSID[i],
551 prScanParam->ucSpecifiedSSIDLen[i]);
554 rCmdScanReq.u2ProbeDelayTime = (UINT_8)prScanParam->u2ProbeDelayTime;
555 rCmdScanReq.ucChannelType = (UINT_8)prScanParam->eScanChannel;
557 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
559 * 1. Specified Listen Channel of passive scan for LISTEN state.
560 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
562 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
564 for(i = 0 ; i < rCmdScanReq.ucChannelListNum ; i++) {
565 rCmdScanReq.arChannelList[i].ucBand =
566 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
568 rCmdScanReq.arChannelList[i].ucChannelNum =
569 (UINT_8)prScanParam->arChnlInfoList[i].ucChannelNum;
573 #if CFG_ENABLE_WIFI_DIRECT
574 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
575 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2PassiveListenInterval;
579 if(prScanParam->u2IELen <= MAX_IE_LENGTH) {
580 rCmdScanReq.u2IELen = prScanParam->u2IELen;
583 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
586 if (prScanParam->u2IELen) {
587 kalMemCopy(rCmdScanReq.aucIE,
589 sizeof(UINT_8) * rCmdScanReq.u2IELen);
592 wlanSendSetQueryCmd(prAdapter,
599 OFFSET_OF(CMD_SCAN_REQ_V2, aucIE) + rCmdScanReq.u2IELen,
600 (PUINT_8)&rCmdScanReq,
607 /*----------------------------------------------------------------------------*/
615 /*----------------------------------------------------------------------------*/
618 IN P_ADAPTER_T prAdapter,
619 IN P_MSG_HDR_T prMsgHdr
622 P_SCAN_INFO_T prScanInfo;
623 P_SCAN_PARAM_T prScanParam;
627 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
628 prScanParam = &prScanInfo->rScanParam;
631 if (prScanInfo->eCurrentState == SCAN_STATE_IDLE) {
632 if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
633 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
634 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
635 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
636 scnFsmHandleScanMsg(prAdapter, (P_MSG_SCN_SCAN_REQ)prMsgHdr);
638 else if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
639 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
640 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
641 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
642 scnFsmHandleScanMsgV2(prAdapter, (P_MSG_SCN_SCAN_REQ_V2)prMsgHdr);
645 // should not deliver to this function
649 cnmMemFree(prAdapter, prMsgHdr);
650 scnFsmSteps(prAdapter, SCAN_STATE_SCANNING);
653 LINK_INSERT_TAIL(&prScanInfo->rPendingMsgList, &prMsgHdr->rLinkEntry);
661 /*----------------------------------------------------------------------------*/
669 /*----------------------------------------------------------------------------*/
672 IN P_ADAPTER_T prAdapter,
673 IN P_MSG_HDR_T prMsgHdr
676 P_MSG_SCN_SCAN_CANCEL prScanCancel;
677 P_SCAN_INFO_T prScanInfo;
678 P_SCAN_PARAM_T prScanParam;
679 CMD_SCAN_CANCEL rCmdScanCancel;
683 prScanCancel = (P_MSG_SCN_SCAN_CANCEL)prMsgHdr;
684 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
685 prScanParam = &prScanInfo->rScanParam;
687 if (prScanInfo->eCurrentState != SCAN_STATE_IDLE) {
688 if(prScanCancel->ucSeqNum == prScanParam->ucSeqNum &&
689 prScanCancel->ucNetTypeIndex == (UINT_8)prScanParam->eNetTypeIndex) {
690 /* send cancel message to firmware domain */
691 rCmdScanCancel.ucSeqNum = prScanParam->ucSeqNum;
693 #if CFG_ENABLE_WIFI_DIRECT
694 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
695 rCmdScanCancel.ucIsExtChannel = (UINT_8) prScanCancel->fgIsChannelExt;
698 rCmdScanCancel.ucIsExtChannel = (UINT_8) FALSE;
702 wlanSendSetQueryCmd(prAdapter,
709 sizeof(CMD_SCAN_CANCEL),
710 (PUINT_8)&rCmdScanCancel,
714 /* generate scan-done event for caller */
715 scnFsmGenerateScanDoneMsg(prAdapter,
716 prScanParam->ucSeqNum,
717 (UINT_8)prScanParam->eNetTypeIndex,
718 SCAN_STATUS_CANCELLED);
720 /* switch to next pending scan */
721 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
724 scnFsmRemovePendingMsg(prAdapter, prScanCancel->ucSeqNum, prScanCancel->ucNetTypeIndex);
728 cnmMemFree(prAdapter, prMsgHdr);
734 /*----------------------------------------------------------------------------*/
736 * \brief Scan Message Parsing (Legacy)
742 /*----------------------------------------------------------------------------*/
744 scnFsmHandleScanMsg (
745 IN P_ADAPTER_T prAdapter,
746 IN P_MSG_SCN_SCAN_REQ prScanReqMsg
749 P_SCAN_INFO_T prScanInfo;
750 P_SCAN_PARAM_T prScanParam;
754 ASSERT(prScanReqMsg);
756 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
757 prScanParam = &prScanInfo->rScanParam;
759 prScanParam->eScanType = prScanReqMsg->eScanType;
760 prScanParam->eNetTypeIndex = (ENUM_NETWORK_TYPE_INDEX_T)prScanReqMsg->ucNetTypeIndex;
761 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
762 if (prScanParam->ucSSIDType & (SCAN_REQ_SSID_SPECIFIED | SCAN_REQ_SSID_P2P_WILDCARD)) {
763 prScanParam->ucSSIDNum = 1;
765 COPY_SSID(prScanParam->aucSpecifiedSSID[0],
766 prScanParam->ucSpecifiedSSIDLen[0],
767 prScanReqMsg->aucSSID,
768 prScanReqMsg->ucSSIDLength);
770 // reset SSID length to zero for rest array entries
771 for(i = 1 ; i < SCN_SSID_MAX_NUM ; i++) {
772 prScanParam->ucSpecifiedSSIDLen[i] = 0;
776 prScanParam->ucSSIDNum = 0;
778 for(i = 0 ; i < SCN_SSID_MAX_NUM ; i++) {
779 prScanParam->ucSpecifiedSSIDLen[i] = 0;
783 prScanParam->u2ProbeDelayTime = 0;
784 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
785 if(prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
786 if(prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
787 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
790 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
793 kalMemCopy(prScanParam->arChnlInfoList,
794 prScanReqMsg->arChnlInfoList,
795 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
798 if(prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
799 prScanParam->u2IELen = prScanReqMsg->u2IELen;
802 prScanParam->u2IELen = MAX_IE_LENGTH;
805 if(prScanParam->u2IELen) {
806 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
809 #if CFG_ENABLE_WIFI_DIRECT
810 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
811 prScanParam->u2PassiveListenInterval = prScanReqMsg->u2ChannelDwellTime;
814 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
816 if(prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
817 prScanParam->fgIsObssScan = TRUE;
820 prScanParam->fgIsObssScan = FALSE;
823 prScanParam->fgIsScanV2 = FALSE;
829 /*----------------------------------------------------------------------------*/
831 * \brief Scan Message Parsing - V2 with multiple SSID support
837 /*----------------------------------------------------------------------------*/
839 scnFsmHandleScanMsgV2 (
840 IN P_ADAPTER_T prAdapter,
841 IN P_MSG_SCN_SCAN_REQ_V2 prScanReqMsg
844 P_SCAN_INFO_T prScanInfo;
845 P_SCAN_PARAM_T prScanParam;
849 ASSERT(prScanReqMsg);
850 ASSERT(prScanReqMsg->ucSSIDNum <= SCN_SSID_MAX_NUM);
852 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
853 prScanParam = &prScanInfo->rScanParam;
855 prScanParam->eScanType = prScanReqMsg->eScanType;
856 prScanParam->eNetTypeIndex = (ENUM_NETWORK_TYPE_INDEX_T)prScanReqMsg->ucNetTypeIndex;
857 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
858 prScanParam->ucSSIDNum = prScanReqMsg->ucSSIDNum;
860 for(i = 0 ; i < prScanReqMsg->ucSSIDNum ; i++) {
861 COPY_SSID(prScanParam->aucSpecifiedSSID[i],
862 prScanParam->ucSpecifiedSSIDLen[i],
863 prScanReqMsg->prSsid[i].aucSsid,
864 (UINT_8)prScanReqMsg->prSsid[i].u4SsidLen);
867 prScanParam->u2ProbeDelayTime = prScanReqMsg->u2ProbeDelay;
868 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
869 if(prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
870 if(prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
871 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
874 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
877 kalMemCopy(prScanParam->arChnlInfoList,
878 prScanReqMsg->arChnlInfoList,
879 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
882 if(prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
883 prScanParam->u2IELen = prScanReqMsg->u2IELen;
886 prScanParam->u2IELen = MAX_IE_LENGTH;
889 if(prScanParam->u2IELen) {
890 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
893 #if CFG_ENABLE_WIFI_DIRECT
894 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
895 prScanParam->u2PassiveListenInterval = prScanReqMsg->u2ChannelDwellTime;
898 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
900 if(prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
901 prScanParam->fgIsObssScan = TRUE;
904 prScanParam->fgIsObssScan = FALSE;
907 prScanParam->fgIsScanV2 = TRUE;
913 /*----------------------------------------------------------------------------*/
915 * \brief Remove pending scan request
921 /*----------------------------------------------------------------------------*/
923 scnFsmRemovePendingMsg (
924 IN P_ADAPTER_T prAdapter,
926 IN UINT_8 ucNetTypeIndex
929 P_SCAN_INFO_T prScanInfo;
930 P_SCAN_PARAM_T prScanParam;
931 P_MSG_HDR_T prPendingMsgHdr, prPendingMsgHdrNext, prRemoveMsgHdr = NULL;
932 P_LINK_ENTRY_T prRemoveLinkEntry = NULL;
936 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
937 prScanParam = &prScanInfo->rScanParam;
939 /* traverse through rPendingMsgList for removal */
940 LINK_FOR_EACH_ENTRY_SAFE(prPendingMsgHdr,
942 &(prScanInfo->rPendingMsgList),
945 if(prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
946 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
947 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
948 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
949 P_MSG_SCN_SCAN_REQ prScanReqMsg = (P_MSG_SCN_SCAN_REQ)prPendingMsgHdr;
951 if(ucSeqNum == prScanReqMsg->ucSeqNum &&
952 ucNetTypeIndex == prScanReqMsg->ucNetTypeIndex) {
953 prRemoveLinkEntry = &(prScanReqMsg->rMsgHdr.rLinkEntry);
954 prRemoveMsgHdr = prPendingMsgHdr;
957 else if(prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
958 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
959 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
960 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
961 P_MSG_SCN_SCAN_REQ_V2 prScanReqMsgV2 = (P_MSG_SCN_SCAN_REQ_V2)prPendingMsgHdr;
963 if(ucSeqNum == prScanReqMsgV2->ucSeqNum &&
964 ucNetTypeIndex == prScanReqMsgV2->ucNetTypeIndex) {
965 prRemoveLinkEntry = &(prScanReqMsgV2->rMsgHdr.rLinkEntry);
966 prRemoveMsgHdr = prPendingMsgHdr;
970 if(prRemoveLinkEntry) {
971 /* generate scan-done event for caller */
972 scnFsmGenerateScanDoneMsg(prAdapter,
975 SCAN_STATUS_CANCELLED);
977 /* remove from pending list */
978 LINK_REMOVE_KNOWN_ENTRY(&(prScanInfo->rPendingMsgList), prRemoveLinkEntry);
979 cnmMemFree(prAdapter, prRemoveMsgHdr);
989 /*----------------------------------------------------------------------------*/
997 /*----------------------------------------------------------------------------*/
1000 IN P_ADAPTER_T prAdapter,
1001 IN P_EVENT_SCAN_DONE prScanDone
1004 P_SCAN_INFO_T prScanInfo;
1005 P_SCAN_PARAM_T prScanParam;
1007 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1008 prScanParam = &prScanInfo->rScanParam;
1010 // buffer empty channel information
1011 if(prScanParam->eScanChannel == SCAN_CHANNEL_FULL
1012 || prScanParam->eScanChannel == SCAN_CHANNEL_2G4) {
1013 if(prScanDone->ucSparseChannelValid) {
1014 prScanInfo->fgIsSparseChannelValid = TRUE;
1015 prScanInfo->rSparseChannel.eBand = (ENUM_BAND_T)prScanDone->rSparseChannel.ucBand;
1016 prScanInfo->rSparseChannel.ucChannelNum = prScanDone->rSparseChannel.ucChannelNum;
1019 prScanInfo->fgIsSparseChannelValid = FALSE;
1023 if(prScanInfo->eCurrentState == SCAN_STATE_SCANNING &&
1024 prScanDone->ucSeqNum == prScanParam->ucSeqNum) {
1025 /* generate scan-done event for caller */
1026 scnFsmGenerateScanDoneMsg(prAdapter,
1027 prScanParam->ucSeqNum,
1028 (UINT_8)prScanParam->eNetTypeIndex,
1031 /* switch to next pending scan */
1032 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
1035 DBGLOG(SCN, LOUD, ("Unexpected SCAN-DONE event: SeqNum = %d, Current State = %d\n",
1036 prScanDone->ucSeqNum,
1037 prScanInfo->eCurrentState));
1041 } /* end of scnEventScanDone */
1044 /*----------------------------------------------------------------------------*/
1052 /*----------------------------------------------------------------------------*/
1054 scnFsmGenerateScanDoneMsg (
1055 IN P_ADAPTER_T prAdapter,
1057 IN UINT_8 ucNetTypeIndex,
1058 IN ENUM_SCAN_STATUS eScanStatus
1061 P_SCAN_INFO_T prScanInfo;
1062 P_SCAN_PARAM_T prScanParam;
1063 P_MSG_SCN_SCAN_DONE prScanDoneMsg;
1067 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1068 prScanParam = &prScanInfo->rScanParam;
1070 prScanDoneMsg = (P_MSG_SCN_SCAN_DONE)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_DONE));
1071 if (!prScanDoneMsg) {
1072 ASSERT(0); // Can't indicate SCAN FSM Complete
1076 if(prScanParam->fgIsObssScan == TRUE) {
1077 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_RLM_SCAN_DONE;
1080 switch((ENUM_NETWORK_TYPE_INDEX_T)ucNetTypeIndex) {
1081 case NETWORK_TYPE_AIS_INDEX:
1082 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_AIS_SCAN_DONE;
1085 #if CFG_ENABLE_WIFI_DIRECT
1086 case NETWORK_TYPE_P2P_INDEX:
1087 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_P2P_SCAN_DONE;
1091 #if CFG_ENABLE_BT_OVER_WIFI
1092 case NETWORK_TYPE_BOW_INDEX:
1093 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_BOW_SCAN_DONE;
1098 DBGLOG(SCN, LOUD, ("Unexpected Network Type: %d\n", ucNetTypeIndex));
1104 prScanDoneMsg->ucSeqNum = ucSeqNum;
1105 prScanDoneMsg->ucNetTypeIndex = ucNetTypeIndex;
1106 prScanDoneMsg->eScanStatus = eScanStatus;
1108 mboxSendMsg(prAdapter,
1110 (P_MSG_HDR_T) prScanDoneMsg,
1111 MSG_SEND_METHOD_BUF);
1113 } /* end of scnFsmGenerateScanDoneMsg() */
1116 /*----------------------------------------------------------------------------*/
1118 * \brief Query for most sparse channel
1124 /*----------------------------------------------------------------------------*/
1126 scnQuerySparseChannel (
1127 IN P_ADAPTER_T prAdapter,
1128 P_ENUM_BAND_T prSparseBand,
1129 PUINT_8 pucSparseChannel
1132 P_SCAN_INFO_T prScanInfo;
1136 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1138 if(prScanInfo->fgIsSparseChannelValid == TRUE) {
1140 *prSparseBand = prScanInfo->rSparseChannel.eBand;
1143 if(pucSparseChannel) {
1144 *pucSparseChannel = prScanInfo->rSparseChannel.ucChannelNum;