2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_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 .
17 * 06 13 2012 yuche.tsai
19 * Update maintrunk driver.
20 * Add support for driver compose assoc request frame.
23 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
24 * Adjust code for DBG and CONFIG_XLOG.
26 * 11 14 2011 yuche.tsai
27 * [WCXRP00001095] [Volunteer Patch][Driver] Always Scan before enable Hot-Spot.
28 * Fix bug when unregister P2P network..
31 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
32 * modify the xlog related code.
35 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
36 * adding the code for XLOG.
39 * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
40 * sparse channel detection:
41 * driver: collect sparse channel information with scan-done event
45 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
46 * free mailbox message afte parsing is completed.
49 * [WCXRP00000858] [MT5931][Driver][Firmware] Add support for scan to search for more than one SSID in a single scanning request
50 * 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
53 * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
54 * Remove flag CFG_WIFI_DIRECT_MOVED.
57 * [WCXRP00000604] [MT6620 Wi-Fi][Driver] Surpress Klockwork Warning
58 * surpress klock warning with code path rewritten
61 * [WCXRP00000576] [MT6620 Wi-Fi][Driver][FW] Remove P2P compile option in scan req/cancel command
64 * 02 18 2011 yuche.tsai
65 * [WCXRP00000478] [Volunteer Patch][MT6620][Driver] Probe request frame during search phase do not contain P2P wildcard SSID.
66 * Take P2P wildcard SSID into consideration.
68 * 01 27 2011 yuche.tsai
69 * [WCXRP00000399] [Volunteer Patch][MT6620/MT5931][Driver] Fix scan side effect after P2P module separate.
70 * Fix scan channel extension issue when p2p module is not registered.
72 * 01 26 2011 yuche.tsai
73 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
76 * 01 25 2011 yuche.tsai
77 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
78 * Fix Compile Error when DBG is disabled.
81 * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
82 * 1. Country code is from NVRAM or supplicant
83 * 2. Change band definition in CMD/EVENT.
85 * 09 03 2010 kevin.huang
87 * Refine #include sequence and solve recursive/nested #include issue
91 * eliminate klockwork errors
95 * add interface for RLM to trigger OBSS-SCAN.
97 * 08 16 2010 yuche.tsai
99 * Fix bug for processing queued scan request.
101 * 08 11 2010 yuche.tsai
103 * Add a function for returning channel.
105 * 08 05 2010 yuche.tsai
107 * Update SCAN FSM for support P2P Device discovery scan.
111 * surpress compilation warning.
113 * 07 26 2010 yuche.tsai
115 * Add option of channel extension while cancelling scan request.
117 * 07 21 2010 yuche.tsai
119 * Add P2P Scan & Scan Result Parsing & Saving.
123 * pass band information for scan in an efficient way by mapping ENUM_BAND_T into UINT_8..
127 * due to FW/DRV won't be sync. precisely, some strict assertions should be eased.
131 * [WPD00003833] [MT6620 and MT5931] Driver migration.
132 * SCN module is now able to handle multiple concurrent scanning requests
136 * [WPD00003833] [MT6620 and MT5931] Driver migration.
137 * bugfix for SCN migration
138 * 1) modify QUEUE_CONCATENATE_QUEUES() so it could be used to concatence with an empty queue
139 * 2) before AIS issues scan request, network(BSS) needs to be activated first
140 * 3) only invoke COPY_SSID when using specified SSID for scan
144 * [WPD00003833] [MT6620 and MT5931] Driver migration.
145 * driver no longer generates probe request frames
149 * [WPD00003833] [MT6620 and MT5931] Driver migration.
150 * pass band with channel number information as scan parameter
154 * [WPD00003833] [MT6620 and MT5931] Driver migration.
155 * remove timer in DRV-SCN.
159 * 1) separate AIS_FSM state for two kinds of scanning. (OID triggered scan, and scan-for-connection)
160 * 2) eliminate PRE_BSS_DESC_T, Beacon/PrebResp is now parsed in single pass
161 * 3) implment DRV-SCN module, currently only accepts single scan request, other request will be directly dropped by returning BUSY
165 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
168 * [WPD00003833][MT6620 and MT5931] Driver migration
169 * take use of RLM module for parsing/generating HT IEs for 11n capability
172 * [WPD00003833][MT6620 and MT5931] Driver migration
173 * when returning to SCAN_IDLE state, send a correct message to source FSM.
176 * [WPD00003833][MT6620 and MT5931] Driver migration
177 * implementation of DRV-SCN and related mailbox message handling.
180 * [WPD00003833][MT6620 and MT5931] Driver migration
181 * comment out RLM APIs by CFG_RLM_MIGRATION.
184 * [WPD00003833][MT6620 and MT5931] Driver migration
185 * add scan_fsm into building.
187 * 05 14 2010 kevin.huang
188 * [BORA00000794][WIFISYS][New Feature]Power Management Support
189 * Refine the order of Stop TX Queue and Switch Channel
191 * 05 12 2010 kevin.huang
192 * [BORA00000794][WIFISYS][New Feature]Power Management Support
193 * Update pause/resume/flush API to new Bitmap API
195 * 05 12 2010 kevin.huang
196 * [BORA00000794][WIFISYS][New Feature]Power Management Support
197 * Add Power Management - Legacy PS-POLL support.
199 * 03 18 2010 kevin.huang
200 * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
201 * Ignore the PROBE_DELAY state if the value of Probe Delay == 0
203 * 03 10 2010 kevin.huang
204 * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
205 * Add Channel Manager for arbitration of JOIN and SCAN Req
207 * 02 23 2010 kevin.huang
208 * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
209 * Add support scan channel 1~14 and update scan result's frequency infou1rwduu`wvpghlqg|n`slk+mpdkb
211 * 01 08 2010 kevin.huang
212 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
213 * Add set RX Filter to receive BCN from different BSSID during SCAN
215 * 12 18 2009 cm.chang
216 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
219 * Nov 25 2009 mtk01461
220 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
221 * Remove flag of CFG_TEST_MGMT_FSM
223 * Nov 20 2009 mtk01461
224 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
225 * Change parameter of scanSendProbeReqFrames()
227 * Nov 16 2009 mtk01461
228 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
229 * Update scnFsmSteps()
231 * Nov 5 2009 mtk01461
232 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
235 * Nov 5 2009 mtk01461
236 * [BORA00000018] Integrate WIFI part into BORA for the 1st time
240 /*******************************************************************************
241 * C O M P I L E R F L A G S
242 ********************************************************************************
245 /*******************************************************************************
246 * E X T E R N A L R E F E R E N C E S
247 ********************************************************************************
251 /*******************************************************************************
253 ********************************************************************************
256 /*******************************************************************************
258 ********************************************************************************
261 /*******************************************************************************
262 * P U B L I C D A T A
263 ********************************************************************************
266 /*******************************************************************************
267 * P R I V A T E D A T A
268 ********************************************************************************
271 /*lint -save -e64 Type mismatch */
272 static PUINT_8 apucDebugScanState[SCAN_STATE_NUM] = {
273 (PUINT_8)DISP_STRING("SCAN_STATE_IDLE"),
274 (PUINT_8)DISP_STRING("SCAN_STATE_SCANNING"),
279 /*******************************************************************************
281 ********************************************************************************
284 /*******************************************************************************
285 * F U N C T I O N D E C L A R A T I O N S
286 ********************************************************************************
289 /*******************************************************************************
291 ********************************************************************************
293 /*----------------------------------------------------------------------------*/
301 /*----------------------------------------------------------------------------*/
304 IN P_ADAPTER_T prAdapter,
305 IN ENUM_SCAN_STATE_T eNextState
308 P_SCAN_INFO_T prScanInfo;
309 P_SCAN_PARAM_T prScanParam;
310 P_MSG_HDR_T prMsgHdr;
312 BOOLEAN fgIsTransition = (BOOLEAN)FALSE;
314 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
315 prScanParam = &prScanInfo->rScanParam;
320 DBGLOG(SCN, STATE, ("TRANSITION: [%s] -> [%s]\n",
321 apucDebugScanState[prScanInfo->eCurrentState],
322 apucDebugScanState[eNextState]));
324 DBGLOG(SCN, STATE, ("[%d] TRANSITION: [%d] -> [%d]\n",
326 prScanInfo->eCurrentState,
330 /* NOTE(Kevin): This is the only place to change the eCurrentState(except initial) */
331 prScanInfo->eCurrentState = eNextState;
333 fgIsTransition = (BOOLEAN)FALSE;
335 switch (prScanInfo->eCurrentState) {
336 case SCAN_STATE_IDLE:
337 /* check for pending scanning requests */
338 if(!LINK_IS_EMPTY(&(prScanInfo->rPendingMsgList))) {
339 // load next message from pending list as scan parameters
340 LINK_REMOVE_HEAD(&(prScanInfo->rPendingMsgList), prMsgHdr, P_MSG_HDR_T);
342 if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
343 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
344 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
345 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
346 scnFsmHandleScanMsg(prAdapter, (P_MSG_SCN_SCAN_REQ)prMsgHdr);
349 scnFsmHandleScanMsgV2(prAdapter, (P_MSG_SCN_SCAN_REQ_V2)prMsgHdr);
352 /* switch to next state */
353 eNextState = SCAN_STATE_SCANNING;
354 fgIsTransition = TRUE;
356 cnmMemFree(prAdapter, prMsgHdr);
360 case SCAN_STATE_SCANNING:
361 if(prScanParam->fgIsScanV2 == FALSE) {
362 scnSendScanReq(prAdapter);
365 scnSendScanReqV2(prAdapter);
375 while (fgIsTransition);
381 /*----------------------------------------------------------------------------*/
383 * \brief Generate CMD_ID_SCAN_REQ command
389 /*----------------------------------------------------------------------------*/
392 IN P_ADAPTER_T prAdapter
395 P_SCAN_INFO_T prScanInfo;
396 P_SCAN_PARAM_T prScanParam;
397 CMD_SCAN_REQ rCmdScanReq;
402 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
403 prScanParam = &prScanInfo->rScanParam;
405 // send command packet for scan
406 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ));
408 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
409 rCmdScanReq.ucNetworkType = (UINT_8)prScanParam->eNetTypeIndex;
410 rCmdScanReq.ucScanType = (UINT_8)prScanParam->eScanType;
411 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
413 if(prScanParam->ucSSIDNum == 1) {
414 COPY_SSID(rCmdScanReq.aucSSID,
415 rCmdScanReq.ucSSIDLength,
416 prScanParam->aucSpecifiedSSID[0],
417 prScanParam->ucSpecifiedSSIDLen[0]);
420 rCmdScanReq.ucChannelType = (UINT_8)prScanParam->eScanChannel;
422 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
424 * 1. Specified Listen Channel of passive scan for LISTEN state.
425 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
427 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
429 for(i = 0 ; i < rCmdScanReq.ucChannelListNum ; i++) {
430 rCmdScanReq.arChannelList[i].ucBand =
431 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
433 rCmdScanReq.arChannelList[i].ucChannelNum =
434 (UINT_8)prScanParam->arChnlInfoList[i].ucChannelNum;
438 #if CFG_ENABLE_WIFI_DIRECT
439 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
440 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2PassiveListenInterval;
445 rCmdScanReq.u2ChannelDwellTime = 200;
446 rCmdScanReq.u2ChannelMinDwellTime = 200;
448 if(prScanParam->u2IELen <= MAX_IE_LENGTH) {
449 rCmdScanReq.u2IELen = prScanParam->u2IELen;
452 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
455 if (prScanParam->u2IELen) {
456 kalMemCopy(rCmdScanReq.aucIE,
458 sizeof(UINT_8) * rCmdScanReq.u2IELen);
461 wlanSendSetQueryCmd(prAdapter,
468 OFFSET_OF(CMD_SCAN_REQ, aucIE) + rCmdScanReq.u2IELen,
469 (PUINT_8)&rCmdScanReq,
475 /*----------------------------------------------------------------------------*/
477 * \brief Generate CMD_ID_SCAN_REQ_V2 command
483 /*----------------------------------------------------------------------------*/
486 IN P_ADAPTER_T prAdapter
489 P_SCAN_INFO_T prScanInfo;
490 P_SCAN_PARAM_T prScanParam;
491 CMD_SCAN_REQ_V2 rCmdScanReq;
496 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
497 prScanParam = &prScanInfo->rScanParam;
499 // send command packet for scan
500 kalMemZero(&rCmdScanReq, sizeof(CMD_SCAN_REQ_V2));
502 rCmdScanReq.ucSeqNum = prScanParam->ucSeqNum;
503 rCmdScanReq.ucNetworkType = (UINT_8)prScanParam->eNetTypeIndex;
504 rCmdScanReq.ucScanType = (UINT_8)prScanParam->eScanType;
505 rCmdScanReq.ucSSIDType = prScanParam->ucSSIDType;
507 for (i = 0 ; i < prScanParam->ucSSIDNum; i++) {
508 COPY_SSID(rCmdScanReq.arSSID[i].aucSsid,
509 rCmdScanReq.arSSID[i].u4SsidLen,
510 prScanParam->aucSpecifiedSSID[i],
511 prScanParam->ucSpecifiedSSIDLen[i]);
514 rCmdScanReq.u2ProbeDelayTime = (UINT_8)prScanParam->u2ProbeDelayTime;
515 rCmdScanReq.ucChannelType = (UINT_8)prScanParam->eScanChannel;
517 if (prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
519 * 1. Specified Listen Channel of passive scan for LISTEN state.
520 * 2. Specified Listen Channel of Target Device of active scan for SEARCH state. (Target != NULL)
522 rCmdScanReq.ucChannelListNum = prScanParam->ucChannelListNum;
524 for(i = 0 ; i < rCmdScanReq.ucChannelListNum ; i++) {
525 rCmdScanReq.arChannelList[i].ucBand =
526 (UINT_8) prScanParam->arChnlInfoList[i].eBand;
528 rCmdScanReq.arChannelList[i].ucChannelNum =
529 (UINT_8)prScanParam->arChnlInfoList[i].ucChannelNum;
533 #if CFG_ENABLE_WIFI_DIRECT
534 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
535 rCmdScanReq.u2ChannelDwellTime = prScanParam->u2PassiveListenInterval;
539 if(prScanParam->u2IELen <= MAX_IE_LENGTH) {
540 rCmdScanReq.u2IELen = prScanParam->u2IELen;
543 rCmdScanReq.u2IELen = MAX_IE_LENGTH;
546 if (prScanParam->u2IELen) {
547 kalMemCopy(rCmdScanReq.aucIE,
549 sizeof(UINT_8) * rCmdScanReq.u2IELen);
552 wlanSendSetQueryCmd(prAdapter,
559 OFFSET_OF(CMD_SCAN_REQ_V2, aucIE) + rCmdScanReq.u2IELen,
560 (PUINT_8)&rCmdScanReq,
567 /*----------------------------------------------------------------------------*/
575 /*----------------------------------------------------------------------------*/
578 IN P_ADAPTER_T prAdapter,
579 IN P_MSG_HDR_T prMsgHdr
582 P_SCAN_INFO_T prScanInfo;
583 P_SCAN_PARAM_T prScanParam;
587 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
588 prScanParam = &prScanInfo->rScanParam;
591 if (prScanInfo->eCurrentState == SCAN_STATE_IDLE) {
592 if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
593 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
594 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
595 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
596 scnFsmHandleScanMsg(prAdapter, (P_MSG_SCN_SCAN_REQ)prMsgHdr);
598 else if(prMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
599 || prMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
600 || prMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
601 || prMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
602 scnFsmHandleScanMsgV2(prAdapter, (P_MSG_SCN_SCAN_REQ_V2)prMsgHdr);
605 // should not deliver to this function
609 cnmMemFree(prAdapter, prMsgHdr);
610 scnFsmSteps(prAdapter, SCAN_STATE_SCANNING);
613 LINK_INSERT_TAIL(&prScanInfo->rPendingMsgList, &prMsgHdr->rLinkEntry);
621 /*----------------------------------------------------------------------------*/
629 /*----------------------------------------------------------------------------*/
632 IN P_ADAPTER_T prAdapter,
633 IN P_MSG_HDR_T prMsgHdr
636 P_MSG_SCN_SCAN_CANCEL prScanCancel;
637 P_SCAN_INFO_T prScanInfo;
638 P_SCAN_PARAM_T prScanParam;
639 CMD_SCAN_CANCEL rCmdScanCancel;
643 prScanCancel = (P_MSG_SCN_SCAN_CANCEL)prMsgHdr;
644 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
645 prScanParam = &prScanInfo->rScanParam;
647 if (prScanInfo->eCurrentState != SCAN_STATE_IDLE) {
648 if(prScanCancel->ucSeqNum == prScanParam->ucSeqNum &&
649 prScanCancel->ucNetTypeIndex == (UINT_8)prScanParam->eNetTypeIndex) {
650 /* send cancel message to firmware domain */
651 rCmdScanCancel.ucSeqNum = prScanParam->ucSeqNum;
653 #if CFG_ENABLE_WIFI_DIRECT
654 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
655 rCmdScanCancel.ucIsExtChannel = (UINT_8) prScanCancel->fgIsChannelExt;
658 rCmdScanCancel.ucIsExtChannel = (UINT_8) FALSE;
662 wlanSendSetQueryCmd(prAdapter,
669 sizeof(CMD_SCAN_CANCEL),
670 (PUINT_8)&rCmdScanCancel,
674 /* generate scan-done event for caller */
675 scnFsmGenerateScanDoneMsg(prAdapter,
676 prScanParam->ucSeqNum,
677 (UINT_8)prScanParam->eNetTypeIndex,
678 SCAN_STATUS_CANCELLED);
680 /* switch to next pending scan */
681 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
684 scnFsmRemovePendingMsg(prAdapter, prScanCancel->ucSeqNum, prScanCancel->ucNetTypeIndex);
688 cnmMemFree(prAdapter, prMsgHdr);
694 /*----------------------------------------------------------------------------*/
696 * \brief Scan Message Parsing (Legacy)
702 /*----------------------------------------------------------------------------*/
704 scnFsmHandleScanMsg (
705 IN P_ADAPTER_T prAdapter,
706 IN P_MSG_SCN_SCAN_REQ prScanReqMsg
709 P_SCAN_INFO_T prScanInfo;
710 P_SCAN_PARAM_T prScanParam;
714 ASSERT(prScanReqMsg);
716 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
717 prScanParam = &prScanInfo->rScanParam;
719 prScanParam->eScanType = prScanReqMsg->eScanType;
720 prScanParam->eNetTypeIndex = (ENUM_NETWORK_TYPE_INDEX_T)prScanReqMsg->ucNetTypeIndex;
721 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
722 if (prScanParam->ucSSIDType & (SCAN_REQ_SSID_SPECIFIED | SCAN_REQ_SSID_P2P_WILDCARD)) {
723 prScanParam->ucSSIDNum = 1;
725 COPY_SSID(prScanParam->aucSpecifiedSSID[0],
726 prScanParam->ucSpecifiedSSIDLen[0],
727 prScanReqMsg->aucSSID,
728 prScanReqMsg->ucSSIDLength);
730 // reset SSID length to zero for rest array entries
731 for(i = 1 ; i < SCN_SSID_MAX_NUM ; i++) {
732 prScanParam->ucSpecifiedSSIDLen[i] = 0;
736 prScanParam->ucSSIDNum = 0;
738 for(i = 0 ; i < SCN_SSID_MAX_NUM ; i++) {
739 prScanParam->ucSpecifiedSSIDLen[i] = 0;
743 prScanParam->u2ProbeDelayTime = 0;
744 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
745 if(prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
746 if(prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
747 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
750 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
753 kalMemCopy(prScanParam->arChnlInfoList,
754 prScanReqMsg->arChnlInfoList,
755 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
758 if(prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
759 prScanParam->u2IELen = prScanReqMsg->u2IELen;
762 prScanParam->u2IELen = MAX_IE_LENGTH;
765 if(prScanParam->u2IELen) {
766 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
769 #if CFG_ENABLE_WIFI_DIRECT
770 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
771 prScanParam->u2PassiveListenInterval = prScanReqMsg->u2ChannelDwellTime;
774 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
776 if(prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
777 prScanParam->fgIsObssScan = TRUE;
780 prScanParam->fgIsObssScan = FALSE;
783 prScanParam->fgIsScanV2 = FALSE;
789 /*----------------------------------------------------------------------------*/
791 * \brief Scan Message Parsing - V2 with multiple SSID support
797 /*----------------------------------------------------------------------------*/
799 scnFsmHandleScanMsgV2 (
800 IN P_ADAPTER_T prAdapter,
801 IN P_MSG_SCN_SCAN_REQ_V2 prScanReqMsg
804 P_SCAN_INFO_T prScanInfo;
805 P_SCAN_PARAM_T prScanParam;
809 ASSERT(prScanReqMsg);
810 ASSERT(prScanReqMsg->ucSSIDNum <= SCN_SSID_MAX_NUM);
812 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
813 prScanParam = &prScanInfo->rScanParam;
815 prScanParam->eScanType = prScanReqMsg->eScanType;
816 prScanParam->eNetTypeIndex = (ENUM_NETWORK_TYPE_INDEX_T)prScanReqMsg->ucNetTypeIndex;
817 prScanParam->ucSSIDType = prScanReqMsg->ucSSIDType;
818 prScanParam->ucSSIDNum = prScanReqMsg->ucSSIDNum;
820 for(i = 0 ; i < prScanReqMsg->ucSSIDNum ; i++) {
821 COPY_SSID(prScanParam->aucSpecifiedSSID[i],
822 prScanParam->ucSpecifiedSSIDLen[i],
823 prScanReqMsg->prSsid[i].aucSsid,
824 (UINT_8)prScanReqMsg->prSsid[i].u4SsidLen);
827 prScanParam->u2ProbeDelayTime = prScanReqMsg->u2ProbeDelay;
828 prScanParam->eScanChannel = prScanReqMsg->eScanChannel;
829 if(prScanParam->eScanChannel == SCAN_CHANNEL_SPECIFIED) {
830 if(prScanReqMsg->ucChannelListNum <= MAXIMUM_OPERATION_CHANNEL_LIST) {
831 prScanParam->ucChannelListNum = prScanReqMsg->ucChannelListNum;
834 prScanParam->ucChannelListNum = MAXIMUM_OPERATION_CHANNEL_LIST;
837 kalMemCopy(prScanParam->arChnlInfoList,
838 prScanReqMsg->arChnlInfoList,
839 sizeof(RF_CHANNEL_INFO_T) * prScanParam->ucChannelListNum);
842 if(prScanReqMsg->u2IELen <= MAX_IE_LENGTH) {
843 prScanParam->u2IELen = prScanReqMsg->u2IELen;
846 prScanParam->u2IELen = MAX_IE_LENGTH;
849 if(prScanParam->u2IELen) {
850 kalMemCopy(prScanParam->aucIE, prScanReqMsg->aucIE, prScanParam->u2IELen);
853 #if CFG_ENABLE_WIFI_DIRECT
854 if(prScanParam->eNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
855 prScanParam->u2PassiveListenInterval = prScanReqMsg->u2ChannelDwellTime;
858 prScanParam->ucSeqNum = prScanReqMsg->ucSeqNum;
860 if(prScanReqMsg->rMsgHdr.eMsgId == MID_RLM_SCN_SCAN_REQ) {
861 prScanParam->fgIsObssScan = TRUE;
864 prScanParam->fgIsObssScan = FALSE;
867 prScanParam->fgIsScanV2 = TRUE;
873 /*----------------------------------------------------------------------------*/
875 * \brief Remove pending scan request
881 /*----------------------------------------------------------------------------*/
883 scnFsmRemovePendingMsg (
884 IN P_ADAPTER_T prAdapter,
886 IN UINT_8 ucNetTypeIndex
889 P_SCAN_INFO_T prScanInfo;
890 P_SCAN_PARAM_T prScanParam;
891 P_MSG_HDR_T prPendingMsgHdr, prPendingMsgHdrNext, prRemoveMsgHdr = NULL;
892 P_LINK_ENTRY_T prRemoveLinkEntry = NULL;
896 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
897 prScanParam = &prScanInfo->rScanParam;
899 /* traverse through rPendingMsgList for removal */
900 LINK_FOR_EACH_ENTRY_SAFE(prPendingMsgHdr,
902 &(prScanInfo->rPendingMsgList),
905 if(prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ
906 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ
907 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ
908 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ) {
909 P_MSG_SCN_SCAN_REQ prScanReqMsg = (P_MSG_SCN_SCAN_REQ)prPendingMsgHdr;
911 if(ucSeqNum == prScanReqMsg->ucSeqNum &&
912 ucNetTypeIndex == prScanReqMsg->ucNetTypeIndex) {
913 prRemoveLinkEntry = &(prScanReqMsg->rMsgHdr.rLinkEntry);
914 prRemoveMsgHdr = prPendingMsgHdr;
917 else if(prPendingMsgHdr->eMsgId == MID_AIS_SCN_SCAN_REQ_V2
918 || prPendingMsgHdr->eMsgId == MID_BOW_SCN_SCAN_REQ_V2
919 || prPendingMsgHdr->eMsgId == MID_P2P_SCN_SCAN_REQ_V2
920 || prPendingMsgHdr->eMsgId == MID_RLM_SCN_SCAN_REQ_V2) {
921 P_MSG_SCN_SCAN_REQ_V2 prScanReqMsgV2 = (P_MSG_SCN_SCAN_REQ_V2)prPendingMsgHdr;
923 if(ucSeqNum == prScanReqMsgV2->ucSeqNum &&
924 ucNetTypeIndex == prScanReqMsgV2->ucNetTypeIndex) {
925 prRemoveLinkEntry = &(prScanReqMsgV2->rMsgHdr.rLinkEntry);
926 prRemoveMsgHdr = prPendingMsgHdr;
930 if(prRemoveLinkEntry) {
931 /* generate scan-done event for caller */
932 scnFsmGenerateScanDoneMsg(prAdapter,
935 SCAN_STATUS_CANCELLED);
937 /* remove from pending list */
938 LINK_REMOVE_KNOWN_ENTRY(&(prScanInfo->rPendingMsgList), prRemoveLinkEntry);
939 cnmMemFree(prAdapter, prRemoveMsgHdr);
949 /*----------------------------------------------------------------------------*/
957 /*----------------------------------------------------------------------------*/
960 IN P_ADAPTER_T prAdapter,
961 IN P_EVENT_SCAN_DONE prScanDone
964 P_SCAN_INFO_T prScanInfo;
965 P_SCAN_PARAM_T prScanParam;
967 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
968 prScanParam = &prScanInfo->rScanParam;
970 // buffer empty channel information
971 if(prScanParam->eScanChannel == SCAN_CHANNEL_FULL
972 || prScanParam->eScanChannel == SCAN_CHANNEL_2G4) {
973 if(prScanDone->ucSparseChannelValid) {
974 prScanInfo->fgIsSparseChannelValid = TRUE;
975 prScanInfo->rSparseChannel.eBand = (ENUM_BAND_T)prScanDone->rSparseChannel.ucBand;
976 prScanInfo->rSparseChannel.ucChannelNum = prScanDone->rSparseChannel.ucChannelNum;
979 prScanInfo->fgIsSparseChannelValid = FALSE;
983 if(prScanInfo->eCurrentState == SCAN_STATE_SCANNING &&
984 prScanDone->ucSeqNum == prScanParam->ucSeqNum) {
985 /* generate scan-done event for caller */
986 scnFsmGenerateScanDoneMsg(prAdapter,
987 prScanParam->ucSeqNum,
988 (UINT_8)prScanParam->eNetTypeIndex,
991 /* switch to next pending scan */
992 scnFsmSteps(prAdapter, SCAN_STATE_IDLE);
995 DBGLOG(SCN, LOUD, ("Unexpected SCAN-DONE event: SeqNum = %d, Current State = %d\n",
996 prScanDone->ucSeqNum,
997 prScanInfo->eCurrentState));
1001 } /* end of scnEventScanDone */
1004 /*----------------------------------------------------------------------------*/
1012 /*----------------------------------------------------------------------------*/
1014 scnFsmGenerateScanDoneMsg (
1015 IN P_ADAPTER_T prAdapter,
1017 IN UINT_8 ucNetTypeIndex,
1018 IN ENUM_SCAN_STATUS eScanStatus
1021 P_SCAN_INFO_T prScanInfo;
1022 P_SCAN_PARAM_T prScanParam;
1023 P_MSG_SCN_SCAN_DONE prScanDoneMsg;
1027 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1028 prScanParam = &prScanInfo->rScanParam;
1030 prScanDoneMsg = (P_MSG_SCN_SCAN_DONE)cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_SCN_SCAN_DONE));
1031 if (!prScanDoneMsg) {
1032 ASSERT(0); // Can't indicate SCAN FSM Complete
1036 if(prScanParam->fgIsObssScan == TRUE) {
1037 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_RLM_SCAN_DONE;
1040 switch((ENUM_NETWORK_TYPE_INDEX_T)ucNetTypeIndex) {
1041 case NETWORK_TYPE_AIS_INDEX:
1042 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_AIS_SCAN_DONE;
1045 #if CFG_ENABLE_WIFI_DIRECT
1046 case NETWORK_TYPE_P2P_INDEX:
1047 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_P2P_SCAN_DONE;
1051 #if CFG_ENABLE_BT_OVER_WIFI
1052 case NETWORK_TYPE_BOW_INDEX:
1053 prScanDoneMsg->rMsgHdr.eMsgId = MID_SCN_BOW_SCAN_DONE;
1058 DBGLOG(SCN, LOUD, ("Unexpected Network Type: %d\n", ucNetTypeIndex));
1064 prScanDoneMsg->ucSeqNum = ucSeqNum;
1065 prScanDoneMsg->ucNetTypeIndex = ucNetTypeIndex;
1066 prScanDoneMsg->eScanStatus = eScanStatus;
1068 mboxSendMsg(prAdapter,
1070 (P_MSG_HDR_T) prScanDoneMsg,
1071 MSG_SEND_METHOD_BUF);
1073 } /* end of scnFsmGenerateScanDoneMsg() */
1076 /*----------------------------------------------------------------------------*/
1078 * \brief Query for most sparse channel
1084 /*----------------------------------------------------------------------------*/
1086 scnQuerySparseChannel (
1087 IN P_ADAPTER_T prAdapter,
1088 P_ENUM_BAND_T prSparseBand,
1089 PUINT_8 pucSparseChannel
1092 P_SCAN_INFO_T prScanInfo;
1096 prScanInfo = &(prAdapter->rWifiVar.rScanInfo);
1098 if(prScanInfo->fgIsSparseChannelValid == TRUE) {
1100 *prSparseBand = prScanInfo->rSparseChannel.eBand;
1103 if(pucSparseChannel) {
1104 *pucSparseChannel = prScanInfo->rSparseChannel.ucChannelNum;