/* ========================================================================== Description: This routine is called at initialization. It returns a channel number that complies to regulation domain and less interference with current enviornment. Return: ch - channel number that NOTE: The retruned channel number is guaranteed to comply to current regulation domain that recorded in pAd->CommonCfg.CountryRegion Usage: 1.) iwpriv ra0 set AutoChannelSel=1 Ues the number of AP and inference status to choose 2.) iwpriv ra0 set AutoChannelSel=2 Ues the False CCA count and Rssi to choose ========================================================================== */ UCHAR APAutoSelectChannel( IN PRTMP_ADAPTER pAd, IN ChannelSel_Alg Alg) { UCHAR ch = 0, i; /* passive scan channel 1-14. collect statistics */ /* In the autochannel select case. AP didn't get channel yet. So have no way to determine which Band AP used by channel number. */ /* Init some structures before doing AutoChannelSelect() */ APAutoChannelInit(pAd); if (( Alg == ChannelAlgRandom ) && (pAd->pChannelInfo->IsABand == TRUE)) { /*for Dfs */ ch = SelectClearChannelRandom(pAd); } else { #ifdef MICROWAVE_OVEN_SUPPORT pAd->CommonCfg.MO_Cfg.bEnable = FALSE; AsicMeasureFalseCCA(pAd); #endif /*find RSSI in each channel */ for (i=0; i<pAd->ChannelListNum; i++) { AsicSwitchChannel(pAd, pAd->ChannelList[i].Channel, TRUE); AsicLockChannel(pAd, pAd->ChannelList[i].Channel);/*do nothing */ pAd->ApCfg.current_channel_index = i; pAd->ApCfg.AutoChannel_Channel = pAd->ChannelList[i].Channel; #ifdef AP_QLOAD_SUPPORT if (QLOAD_DOES_ALARM_OCCUR(pAd)) { /* QLOAD ALARM, ever alarm from QLOAD module */ OS_WAIT(400); /* wait for 400 ms at each channel. */ } else #endif /* AP_QLOAD_SUPPORT */ { OS_WAIT(200); /* wait for 200 ms at each channel. */ } UpdateChannelInfo(pAd, i,Alg); } ch = SelectBestChannel(pAd, Alg); } return ch; }
/* ========================================================================== Description: This routine is called at initialization. It returns a channel number that complies to regulation domain and less interference with current enviornment. Return: ch - channel number that NOTE: The retruned channel number is guaranteed to comply to current regulation domain that recorded in pAd->CommonCfg.CountryRegion Usage: 1.) iwpriv ra0 set AutoChannelSel=1 Ues the number of AP and inference status to choose 2.) iwpriv ra0 set AutoChannelSel=2 Ues the False CCA count and Rssi to choose ========================================================================== */ UCHAR APAutoSelectChannel(RTMP_ADAPTER *pAd, ChannelSel_Alg Alg) { UCHAR ch = 0; #ifndef SUPPORT_ACS_BY_SCAN UCHAR i = 0; #endif /* passive scan channel 1-14. collect statistics */ DBGPRINT(RT_DEBUG_TRACE, ("Entering ACS (Alg=%d)...\n", Alg)); /* In the autochannel select case. AP didn't get channel yet. So have no way to determine which Band AP used by channel number. */ /* Init some structures before doing AutoChannelSelect() */ APAutoChannelInit(pAd); if (( Alg == ChannelAlgRandom ) && (pAd->pChannelInfo->IsABand == TRUE)) { /*for Dfs */ DBGPRINT(RT_DEBUG_TRACE, ("ACS: Select from random\n")); ch = SelectClearChannelRandom(pAd); } else { #ifndef SUPPORT_ACS_BY_SCAN /*find RSSI in each channel */ DBGPRINT(RT_DEBUG_TRACE, ("Start ACS scan (total channel = %d, stay_time = %dms)\n", pAd->ChannelListNum, AUTO_CHANNEL_SEL_TIMEOUT)); for (i=0; i<pAd->ChannelListNum; i++) { AsicSwitchChannel(pAd, pAd->ChannelList[i].Channel, TRUE); AsicLockChannel(pAd, pAd->ChannelList[i].Channel); /*do nothing */ pAd->ApCfg.current_channel_index = i; pAd->ApCfg.AutoChannel_Channel = pAd->ChannelList[i].Channel; OS_WAIT(AUTO_CHANNEL_SEL_TIMEOUT); /* wait for 200 ms at each channel. */ UpdateChannelInfo(pAd, i, Alg); } DBGPRINT(RT_DEBUG_TRACE, ("ACS scan complete)\n")); #ifdef SUPPORT_ACS_ALL_CHANNEL_RANK if ((ch = ACS_PerformAlgorithm(pAd, Alg)) <= 0) { /* return ch is the total number of channels in the rank list */ DBGPRINT(RT_DEBUG_ERROR, ("ACS: Error perform algorithm!\n")); } else DBGPRINT(RT_DEBUG_ERROR, ("ACS: Perform algorithm OK (ch_count=%d)!\n", ch)); #else ch = SelectBestChannel(pAd, Alg); #endif /* SUPPORT_ACS_ALL_CHANNEL_RANK */ #endif /* SUPPORT_ACS_BY_SCAN */ } return ch; }
/* ========================================================================== Description: This routine is called at initialization. It returns a channel number that complies to regulation domain and less interference with current enviornment. Return: ch - channel number that NOTE: The retruned channel number is guaranteed to comply to current regulation domain that recorded in pAd->CommonCfg.CountryRegion Usage: 1.) iwpriv ra0 set AutoChannelSel=1 Ues the number of AP and inference status to choose 2.) iwpriv ra0 set AutoChannelSel=2 Ues the False CCA count and Rssi to choose ========================================================================== */ UCHAR APAutoSelectChannel( IN PRTMP_ADAPTER pAd, IN ChannelSel_Alg Alg) { UCHAR ch = 0, i; // passive scan channel 1-14. collect statistics // In the autochannel select case. AP didn't get channel yet. // So have no way to determine which Band AP used by channel number. // // Init some structures before doing AutoChannelSelect() // APAutoChannelInit(pAd); if (( Alg == ChannelAlgRandom ) && (pAd->pChannelInfo->IsABand == TRUE)) { //for Dfs ch = SelectClearChannelRandom(pAd); } else { //find RSSI in each channel // for (i=0; i<pAd->ChannelListNum; i++) { AsicSwitchChannel(pAd, pAd->ChannelList[i].Channel, TRUE); AsicLockChannel(pAd, pAd->ChannelList[i].Channel);//do nothing pAd->ApCfg.current_channel_index = i; pAd->ApCfg.AutoChannel_Channel = pAd->ChannelList[i].Channel; #ifdef AP_QLOAD_SUPPORT if (QLOAD_DOES_ALARM_OCCUR(pAd)) { /* QLOAD ALARM, ever alarm from QLOAD module */ OS_WAIT(400); // wait for 400 ms at each channel. } else #endif { OS_WAIT(200); // wait for 200 ms at each channel. } UpdateChannelInfo(pAd, i,Alg); } ch = SelectBestChannel(pAd, Alg); } return ch; }
static VOID ApCliMlmeScanReqAction( IN RTMP_ADAPTER *pAd, IN MLME_QUEUE_ELEM *Elem) { BOOLEAN Cancelled; UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType; /* Suspend MSDU transmission here */ RTMPSuspendMsduTransmission(pAd); /* first check the parameter sanity */ if (MlmeScanReqSanity(pAd, Elem->Msg, Elem->MsgLen, &BssType, (PCHAR)Ssid, &SsidLen, &ScanType)) { DBGPRINT(RT_DEBUG_TRACE, ("%s(): mlme scan req action!\n", __FUNCTION__)); NdisGetSystemUpTime(&pAd->ApCfg.LastScanTime); RTMPCancelTimer(&pAd->MlmeAux.APScanTimer, &Cancelled); /* record desired BSS parameters */ pAd->MlmeAux.BssType = BssType; pAd->MlmeAux.ScanType = ScanType; pAd->MlmeAux.SsidLen = SsidLen; NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen); /* start from the first channel */ #ifdef AP_PARTIAL_SCAN_SUPPORT pAd->MlmeAux.Channel = RTMPFindScanChannel(pAd, 0); #else pAd->MlmeAux.Channel = FirstChannel(pAd); #endif /* AP_PARTIAL_SCAN_SUPPORT */ /* Let BBP register at 20MHz to do scan */ bbp_set_bw(pAd, BW_20); DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n")); #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { if (pAd->ApCfg.bAutoChannelAtBootup == TRUE)/* iwpriv set auto channel selection */ { APAutoChannelInit(pAd); pAd->ApCfg.AutoChannel_Channel = pAd->ChannelList[0].Channel; } #ifdef SMART_MESH Set_Scan_False_CCA(pAd, 0, CCA_RESET); #endif /* SMART_MESH */ } #endif /* CONFIG_AP_SUPPORT */ ScanNextChannel(pAd, OPMODE_AP, INT_APCLI); }