INT Set_P2P_Reset_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { /*UINT32 DiscPerd = 0;*/ POS_COOKIE pObj; PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; if (P2P_CLI_ON(pAd)) P2P_CliStop(pAd); else if (P2P_GO_ON(pAd)) { P2P_GoStop(pAd); if (INFRA_ON(pAd)) AsicEnableBssSync(pAd); } P2PCfgInit(pAd); P2pGroupTabInit(pAd); pP2PCtrl->Rule = P2P_IS_DEVICE; pAd->flg_p2p_OpStatusFlags = P2P_DISABLE; pP2PCtrl->ConfigMethod = 0x188; pAd->ApCfg.MBSSID[MAIN_MBSSID].WscControl.WscConfStatus = WSC_SCSTATE_UNCONFIGURED; pP2PCtrl->GoFormCurrentState = P2P_GO_FORM_IDLE; pP2PCtrl->DiscCurrentState = P2P_DISC_IDLE; pP2PCtrl->CtrlCurrentState = P2P_CTRL_IDLE; NdisZeroMemory(&pP2PCtrl->P2pCounter, sizeof(P2P_COUNTER_STRUCT)); pP2PCtrl->P2PConnectState = P2P_CONNECT_IDLE; return TRUE; }
// Periodic Radar detection, switch channel will occur in RTMPHandleTBTTInterrupt() // Before switch channel, driver needs doing channel switch announcement. VOID RadarDetectPeriodic( IN PRTMP_ADAPTER pAd) { // need to check channel availability, after switch channel if (pAd->CommonCfg.RadarDetect.RDMode != RD_SILENCE_MODE) return; // channel availability check time is 60sec, use 65 for assurance if (pAd->CommonCfg.RadarDetect.RDCount++ > pAd->CommonCfg.RadarDetect.ChMovingTime) { DBGPRINT(RT_DEBUG_TRACE, ("Not found radar signal, start send beacon and radar detection in service monitor\n\n")); BbpRadarDetectionStop(pAd); AsicEnableBssSync(pAd); pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE; return; } return; }
static INT CFG80211_VirtualIF_Close(struct net_device *dev_p) { struct rtmp_adapter *pAd; pAd = RTMP_OS_NETDEV_GET_PRIV(dev_p); ASSERT(pAd); DBGPRINT(RT_DEBUG_TRACE, ("%s: ===> %s\n", __FUNCTION__, RTMP_OS_NETDEV_GET_DEVNAME(dev_p))); RTMP_OS_NETDEV_STOP_QUEUE(dev_p); if (netif_carrier_ok(dev_p)) netif_carrier_off(dev_p); #ifdef CONFIG_STA_SUPPORT if (INFRA_ON(pAd)) AsicEnableBssSync(pAd); else if (ADHOC_ON(pAd)) AsicEnableIbssSync(pAd); #else else AsicDisableSync(pAd); #endif //VIRTUAL_IF_DOWN(pAd); RT_MOD_DEC_USE_COUNT(); return 0; }
/* Before switch channel, driver needs doing channel switch announcement.*/ VOID RadarDetectPeriodic( IN PRTMP_ADAPTER pAd) { INT i, ChIdx = 0, bAnyUnavailableChannel = FALSE; /* 1. APStart(), CalBufTime = 0; 2. if bAnyUnavailableChannel, CalBufTime = DEFAULT_CAL_BUF_TIME; 3. if Calibrated, CalBufTime = DEFAULT_CAL_BUF_TIME_MAX; */ for (i=0; i<pAd->ChannelListNum; i++) { if (pAd->ChannelList[i].RemainingTimeForUse != 0) { bAnyUnavailableChannel = TRUE; } if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel) { ChIdx = i; } } if (bAnyUnavailableChannel) pAd->Dot11_H.CalBufTime = DEFAULT_CAL_BUF_TIME; if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { /* In Silent Mode, RDCount is use to check with the CAC Time */ if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime && pAd->ChannelList[ChIdx].RemainingTimeForUse == 0) { MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_TRACE, ("Not found radar signal, start send beacon and radar detection in service monitor\n\n")); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; AsicEnableBssSync(pAd, pAd->CommonCfg.BeaconPeriod); pAd->Dot11_H.RDCount = 0; } } else if (pAd->Dot11_H.RDMode == RD_NORMAL_MODE) { if (!bAnyUnavailableChannel) { pAd->Dot11_H.RDCount++; /* In Normal Mode, RDCount is use to check with the CalBufTime */ if ((pAd->Dot11_H.RDCount >= pAd->Dot11_H.CalBufTime)) { pAd->Dot11_H.CalBufTime = DEFAULT_CAL_BUF_TIME_MAX; } } } }
static VOID ApCliTrialConnectTimeout( IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3) { PAPCLI_STRUCT pApCliEntry = (APCLI_STRUCT *)FunctionContext; RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)pApCliEntry->pAd; UCHAR ifIndex = pApCliEntry->ifIndex; UCHAR BBPValue; PULONG pCurrState = &pAd->ApCfg.ApCliTab[ifIndex].CtrlCurrState; DBGPRINT(RT_DEBUG_TRACE, ("ApCli_SYNC - TrialConnectTimeout, Jump back to original Channel\n")); AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, TRUE); AsicEnableBssSync(pAd);//jump back to origin channel, regenerate beacon. if (pAd->CommonCfg.BBPCurrentBW == BW_40) { } if (*pCurrState == APCLI_CTRL_ASSOC) { //trialConnectTimeout, and currect status is ASSOC, //it means we got Auth Resp from new root AP already, //we shall serve the origin channel traffic first, //and jump back to trial channel to issue Assoc Req later, //and finish four way-handshake if need. DBGPRINT(RT_DEBUG_TRACE, ("%s, ApCliTrialConnectTimeout APCLI_CTRL_ASSOC set TrialConnectPhase2Timer\n", __func__)); RTMPSetTimer(&(pApCliEntry->TrialConnectPhase2Timer), TRIAL_TIMEOUT); } else { //RTMPCancelTimer(&(pApCliEntry->ApCliMlmeAux.ProbeTimer), &Cancelled); pApCliEntry->NewRootApRetryCnt++; if (pApCliEntry->NewRootApRetryCnt >= 10) { DBGPRINT(RT_DEBUG_TRACE, ("%s, RetryCnt:%d, pCurrState = %d, \n", __func__, pApCliEntry->NewRootApRetryCnt, *pCurrState)); pApCliEntry->TrialCh=0; MlmeEnqueue(pAd, APCLI_CTRL_STATE_MACHINE, APCLI_CTRL_DISCONNECT_REQ, 0, NULL, ifIndex); NdisZeroMemory(pAd->ApCfg.ApCliTab[ifIndex].CfgSsid, MAX_LEN_OF_SSID);//cleanup CfgSsid. pApCliEntry->CfgSsidLen = 0; pApCliEntry->NewRootApRetryCnt = 0;//cleanup retry count pApCliEntry->Enable = FALSE; } else *pCurrState = APCLI_CTRL_DISCONNECTED;//Disconnected State will bring the next probe req, auth req. } return; }
// Periodic Radar detection, switch channel will occur in RTMPHandleTBTTInterrupt() // Before switch channel, driver needs doing channel switch announcement. VOID RadarDetectPeriodic( IN PRTMP_ADAPTER pAd) { // need to check channel availability, after switch channel if (pAd->CommonCfg.RadarDetect.RDMode != RD_SILENCE_MODE) return; // channel availability check time is 60sec, use 65 for assurance if (pAd->CommonCfg.RadarDetect.RDCount++ > pAd->CommonCfg.RadarDetect.ChMovingTime) { DBGPRINT(RT_DEBUG_TRACE, ("Not found radar signal, start send beacon and radar detection in service monitor\n\n")); BbpRadarDetectionStop(pAd); #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef CARRIER_DETECTION_SUPPORT if (pAd->CommonCfg.CarrierDetect.Enable == TRUE) { // trun on Carrier-Detection. (Carrier-Detect with CTS protection). CARRIER_DETECT_START(pAd, 1); } #endif // CARRIER_DETECTION_SUPPORT // } #endif // CONFIG_AP_SUPPORT // AsicEnableBssSync(pAd); pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE; #ifdef DFS_MERGE_ARCH_TEAM if (pAd->CommonCfg.dfs_func < 1) AdaptRadarDetection(pAd); #else #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef DFS_SUPPORT AdaptRadarDetection(pAd); // start radar detection. #endif // DFS_SUPPORT // } #endif // CONFIG_AP_SUPPORT // #endif // DFS_MERGE_ARCH_TEAM // return; }
static INT CFG80211_VirtualIF_Close(PNET_DEV dev_p) { VOID *pAdSrc; pAdSrc = RTMP_OS_NETDEV_GET_PRIV(dev_p); ASSERT(pAdSrc); PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; #ifdef RT_CFG80211_P2P_SUPPORT if (dev_p->ieee80211_ptr->iftype == RT_CMD_80211_IFTYPE_P2P_CLIENT) { DBGPRINT(RT_DEBUG_TRACE, ("CFG80211_VirtualIF_Close\n")); CFG80211OS_ScanEnd(pAd->pCfg80211_CB, TRUE); RT_MOD_DEC_USE_COUNT(); return ApCli_Close(pAd, dev_p); } #endif /* RT_CFG80211_P2P_SUPPORT */ #ifdef CONFIG_SNIFFER_SUPPORT #ifdef CONFIG_AP_SUPPORT if(dev_p->ieee80211_ptr->iftype == RT_CMD_80211_IFTYPE_MONITOR) { pAd->ApCfg.BssType = BSS_INFRA; AsicSetRxFilter(pAd); } #endif /*CONFIG_AP_SUPPORT*/ #endif /*CONFIG_SNIFFER_SUPPORT*/ DBGPRINT(RT_DEBUG_TRACE, ("%s: ===> %s\n", __FUNCTION__, RTMP_OS_NETDEV_GET_DEVNAME(dev_p))); RTMP_OS_NETDEV_STOP_QUEUE(dev_p); if (netif_carrier_ok(dev_p)) netif_carrier_off(dev_p); #ifdef CONFIG_STA_SUPPORT if (INFRA_ON(pAd)) AsicEnableBssSync(pAd); else if (ADHOC_ON(pAd)) AsicEnableIbssSync(pAd); #else else AsicDisableSync(pAd); #endif //VIRTUAL_IF_DOWN(pAd); RT_MOD_DEC_USE_COUNT(); return 0; }
/* Before switch channel, driver needs doing channel switch announcement.*/ VOID RadarDetectPeriodic( IN PRTMP_ADAPTER pAd) { INT i, ChIdx = 0; /* 1. APStart(), CalBufTime = 0; 2. if bAnyUnavailableChannel, CalBufTime = DEFAULT_CAL_BUF_TIME; 3. if Calibrated, CalBufTime = DEFAULT_CAL_BUF_TIME_MAX; */ for (i=0; i<pAd->ChannelListNum; i++) { if (pAd->CommonCfg.Channel == pAd->ChannelList[i].Channel) { ChIdx = i; } } if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { /* In Silent Mode, RDCount is use to check with the CAC Time */ if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime && pAd->ChannelList[ChIdx].RemainingTimeForUse == 0) { DBGPRINT(RT_DEBUG_TRACE, ("Not found radar signal, start send beacon and radar detection in service monitor\n\n")); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; AsicEnableBssSync(pAd); #ifdef MT76x2 if (IS_MT76x2(pAd)) { mt76x2_tssi_calibration(pAd, pAd->hw_cfg.cent_ch); #ifdef TXBF_SUPPORT if (pAd->hw_cfg.cent_ch > 14) rtmp_ate_txbf_fix_tank_code(pAd, pAd->hw_cfg.cent_ch, 0); // load tank code from efuse, iBF only for A band #endif /* TXBF_SUPPORT */ mt76x2_calibration(pAd, pAd->hw_cfg.cent_ch); } #endif /* MT76x2 */ pAd->Dot11_H.RDCount = 0; } } }
static INT CFG80211_VirtualIF_Close(PNET_DEV dev_p) { VOID *pAdSrc; pAdSrc = RTMP_OS_NETDEV_GET_PRIV(dev_p); ASSERT(pAdSrc); PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; if ((dev_p->ieee80211_ptr->iftype == RT_CMD_80211_IFTYPE_P2P_CLIENT) #ifdef CFG80211_MULTI_STA || (dev_p->ieee80211_ptr->iftype == RT_CMD_80211_IFTYPE_STATION) #endif /* CFG80211_MULTI_STA */ ) { DBGPRINT(RT_DEBUG_TRACE, ("CFG80211_VirtualIF_Close\n")); CFG80211OS_ScanEnd(pAd->pCfg80211_CB, TRUE); if (pAd->cfg80211_ctrl.FlgCfg80211Scanning) pAd->cfg80211_ctrl.FlgCfg80211Scanning = FALSE; RT_MOD_DEC_USE_COUNT(); return ApCli_Close(pAd, dev_p); } DBGPRINT(RT_DEBUG_TRACE, ("%s: ===> %s\n", __FUNCTION__, RTMP_OS_NETDEV_GET_DEVNAME(dev_p))); RTMP_OS_NETDEV_STOP_QUEUE(dev_p); if (netif_carrier_ok(dev_p)) netif_carrier_off(dev_p); if (INFRA_ON(pAd)) AsicEnableBssSync(pAd, pAd->CommonCfg.BeaconPeriod); else if (ADHOC_ON(pAd)) AsicEnableIbssSync(pAd); else AsicDisableSync(pAd); //VIRTUAL_IF_DOWN(pAd); RT_MOD_DEC_USE_COUNT(); return 0; }
INT Set_P2P_Reset_Proc( IN PRTMP_ADAPTER pAd, IN PSTRING arg) { /*UINT32 DiscPerd = 0;*/ POS_COOKIE pObj; PRT_P2P_CONFIG pP2PCtrl = &pAd->P2pCfg; pObj = (POS_COOKIE) pAd->OS_Cookie; if (pObj->ioctl_if_type != INT_P2P) return 0; if (P2P_CLI_ON(pAd)) P2P_CliStop(pAd); else if (P2P_GO_ON(pAd)) { P2P_GoStop(pAd); if (INFRA_ON(pAd)) AsicEnableBssSync(pAd); } P2PCfgInit(pAd); P2pGroupTabInit(pAd); pP2PCtrl->Rule = P2P_IS_DEVICE; pAd->flg_p2p_OpStatusFlags = P2P_DISABLE; pP2PCtrl->ConfigMethod = 0x188; pAd->ApCfg.MBSSID[MAIN_MBSSID].WscControl.WscConfStatus = WSC_SCSTATE_UNCONFIGURED; pP2PCtrl->GoFormCurrentState = P2P_GO_FORM_IDLE; pP2PCtrl->DiscCurrentState = P2P_DISC_IDLE; pP2PCtrl->CtrlCurrentState = P2P_CTRL_IDLE; NdisZeroMemory(&pP2PCtrl->P2pCounter, sizeof(P2P_COUNTER_STRUCT)); P2pSetListenIntBias(pAd, 3); RTMPZeroMemory(pAd->P2pCfg.SSID, MAX_LEN_OF_SSID); RTMPMoveMemory(pAd->P2pCfg.SSID, WILDP2PSSID, WILDP2PSSIDLEN); pP2PCtrl->SSIDLen = WILDP2PSSIDLEN; /* Set Dpid to "not specified". it means, GUI doesn't set for connection yet. */ pP2PCtrl->Dpid = DEV_PASS_ID_NOSPEC; RTMPZeroMemory(pAd->P2pCfg.ConnectingMAC, MAC_ADDR_LEN); return TRUE; }
static INT scan_ch_restore(RTMP_ADAPTER *pAd, UCHAR OpMode) { INT bw, ch; if (pAd->CommonCfg.BBPCurrentBW != pAd->hw_cfg.bbp_bw) bbp_set_bw(pAd, pAd->hw_cfg.bbp_bw); #ifdef DOT11_VHT_AC if (pAd->hw_cfg.bbp_bw == BW_80) ch = pAd->CommonCfg.vht_cent_ch; else #endif /* DOT11_VHT_AC */ if (pAd->hw_cfg.bbp_bw == BW_40) ch = pAd->CommonCfg.CentralChannel; else ch = pAd->CommonCfg.Channel; ASSERT((ch != 0)); AsicSwitchChannel(pAd, ch, FALSE); AsicLockChannel(pAd, ch); switch(pAd->CommonCfg.BBPCurrentBW) { case BW_80: bw = 80; break; case BW_40: bw = 40; break; case BW_10: bw = 10; break; case BW_20: default: bw =20; break; } DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to %dMHz channel %d, Total BSS[%02d]\n", bw, ch, pAd->ScanTab.BssNr)); #ifdef CONFIG_AP_SUPPORT if (OpMode == OPMODE_AP) { #ifdef APCLI_SUPPORT #ifdef APCLI_AUTO_CONNECT_SUPPORT if (pAd->ApCfg.ApCliAutoConnectRunning == TRUE) { if (!ApCliAutoConnectExec(pAd)) { DBGPRINT(RT_DEBUG_ERROR, ("Error in %s\n", __FUNCTION__)); } } #endif /* APCLI_AUTO_CONNECT_SUPPORT */ #endif /* APCLI_SUPPORT */ pAd->Mlme.ApSyncMachine.CurrState = AP_SYNC_IDLE; RTMPResumeMsduTransmission(pAd); /* iwpriv set auto channel selection*/ /* scanned all channels*/ if (pAd->ApCfg.bAutoChannelAtBootup==TRUE) { pAd->CommonCfg.Channel = SelectBestChannel(pAd, pAd->ApCfg.AutoChannelAlg); pAd->ApCfg.bAutoChannelAtBootup = FALSE; #ifdef DOT11_N_SUPPORT N_ChannelCheck(pAd); #endif /* DOT11_N_SUPPORT */ APStop(pAd); APStartUp(pAd); } if (!((pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == TRUE) && (pAd->Dot11_H.RDMode != RD_NORMAL_MODE))) AsicEnableBssSync(pAd, pAd->CommonCfg.BeaconPeriod); } #endif /* CONFIG_AP_SUPPORT */ return TRUE; }
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { PCARRIER_DETECTION_STRUCT pCarrierDetect = &pAd->CommonCfg.CarrierDetect; if (pCarrierDetect->OneSecIntCount < pCarrierDetect->CarrierGoneThreshold) { pCarrierDetect->CD_State = CD_NORMAL; pCarrierDetect->recheck = pCarrierDetect->recheck1; if (pCarrierDetect->Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd); } else { printk("Carrier gone\n"); } } pCarrierDetect->OneSecIntCount = 0; } #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ AsicAdjustTxPower(pAd); /*#endif // WIFI_TEST */ #ifdef RTMP_TEMPERATURE_COMPENSATION MT76x0_TemperatureCompensation(pAd); #endif /* RTMP_TEMPERATURE_COMPENSATION */ /* BBP TUNING: dynamic tune BBP R66 to find a balance between sensibility and noise isolation */ /* AsicBbpTuning2(pAd); */ /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); #ifdef FPGA_MODE if (pAd->fpga_tr_stop) { UINT32 mac_val; /* enable/disable tx/rx*/ RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &mac_val); switch (pAd->fpga_tr_stop) { case 3: //stop tx + rx mac_val &= (~0xc); break; case 2: // stop rx mac_val &= (~0x8); break; case 1: // stop tx mac_val &= (~0x4); break; case 4: default: mac_val |= 0x0c; break; } RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, mac_val); } #endif /* FGPA_MODE */ RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1) ApCliIfUp(pAd); { INT loop; ULONG Now32; UINT32 MaxWcidNum = MAX_LEN_OF_MAC_TABLE; #ifdef MAC_REPEATER_SUPPORT if (pAd->ApCfg.bMACRepeaterEn) { MaxWcidNum = MAX_MAC_TABLE_SIZE_WITH_REPEATER; #ifdef APCLI_AUTO_CONNECT_SUPPORT RTMPRepeaterReconnectionCheck(pAd); #endif /* APCLI_AUTO_CONNECT_SUPPORT */ } #endif /* MAC_REPEATER_SUPPORT */ NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MaxWcidNum)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) { AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1) ) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->Dot11_H.InServiceMonitorCount++; if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime) { AsicEnableBssSync(pAd); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; } } #endif /* !DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ /* resume Improved Scanning*/ if ((pAd->ApCfg.bImprovedScan) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)) && (pAd->Mlme.ApSyncMachine.CurrState == AP_SCAN_PENDING)) { MLME_SCAN_REQ_STRUCT ScanReq; AsicDisableSync(pAd); RTMPZeroMemory(ScanReq.Ssid, MAX_LEN_OF_SSID); ScanReq.SsidLen = pAd->MlmeAux.SsidLen; NdisMoveMemory(ScanReq.Ssid, pAd->MlmeAux.Ssid, ScanReq.SsidLen); ScanReq.BssType = BSS_ANY; #ifdef APCLI_CONNECTION_TRIAL ScanReq.ScanType = FAST_SCAN_ACTIVE; #else ScanReq.ScanType = SCAN_ACTIVE; #endif /* APCLI_CONNECTION_TRIAL */ MlmeEnqueue(pAd, AP_SYNC_STATE_MACHINE, APMT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq, 0); RTMP_MLME_HANDLER(pAd); DBGPRINT(RT_DEBUG_TRACE, ("bImprovedScan ............. Resume for bImprovedScan, SCAN_PENDING .............. \n")); } }
/* ========================================================================== Description: Scan next channel ========================================================================== */ VOID ScanNextChannel( IN PRTMP_ADAPTER pAd) { HEADER_802_11 Hdr80211; PUCHAR pOutBuffer = NULL; NDIS_STATUS NStatus; ULONG FrameLen = 0; UCHAR SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0; UINT ScanTimeIn5gChannel = SHORT_CHANNEL_TIME; BOOLEAN ScanPending = FALSE; #ifdef RALINK_ATE // Nothing to do in ATE mode. if (ATE_ON(pAd)) return; #endif // RALINK_ATE // if ((pAd->MlmeAux.Channel == 0) || ScanPending) { if ((pAd->CommonCfg.BBPCurrentBW == BW_40) ) { AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel); RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue); BBPValue &= (~0x18); BBPValue |= 0x10; RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue); DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr)); } else { AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.Channel); DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr)); } #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { pAd->Mlme.ApSyncMachine.CurrState = AP_SYNC_IDLE; RTMPResumeMsduTransmission(pAd); // iwpriv set auto channel selection // scanned all channels if (pAd->ApCfg.bAutoChannelAtBootup==TRUE) { pAd->CommonCfg.Channel = SelectBestChannel(pAd, pAd->ApCfg.AutoChannelAlg); pAd->ApCfg.bAutoChannelAtBootup = FALSE; #ifdef DOT11_N_SUPPORT N_ChannelCheck(pAd); #endif // DOT11_N_SUPPORT // APStop(pAd); APStartUp(pAd); } if (!((pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == TRUE))) { AsicEnableBssSync(pAd); } } #endif // CONFIG_AP_SUPPORT // } else {
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ /* We return here in ATE mode, because the statistics that ATE need are not collected via this routine. */ #ifdef RALINK_ATE if (ATE_ON(pAd)) return; #endif /* RALINK_ATE */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { if (pAd->CommonCfg.CarrierDetect.OneSecIntCount < pAd->CommonCfg.CarrierDetect.CarrierGoneThreshold) { pAd->CommonCfg.CarrierDetect.CD_State = CD_NORMAL; pAd->CommonCfg.CarrierDetect.recheck = pAd->CommonCfg.CarrierDetect.recheck1; if (pAd->CommonCfg.CarrierDetect.Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd); } else { printk("Carrier gone\n"); } } } pAd->CommonCfg.CarrierDetect.OneSecIntCount = 0; #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ AsicAdjustTxPower(pAd); /*#endif // WIFI_TEST */ /* BBP TUNING: dynamic tune BBP R66 to find a balance between sensibility and noise isolation */ /* AsicBbpTuning2(pAd); */ /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1) ApCliIfUp(pAd); { INT loop; ULONG Now32; NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MAX_LEN_OF_MAC_TABLE)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) { AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1) ) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->CommonCfg.InServiceMonitorCount++; if (pAd->CommonCfg.RDMode == RD_SILENCE_MODE) { if (pAd->CommonCfg.RDCount++ > pAd->CommonCfg.ChMovingTime) { AsicEnableBssSync(pAd); pAd->CommonCfg.RDMode = RD_NORMAL_MODE; } } #endif /* DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ }
static INT CFG80211_DummyP2pIf_Close( IN PNET_DEV dev_p) { struct wireless_dev *wdev = dev_p->ieee80211_ptr; #ifdef RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE VOID *pAdSrc; pAdSrc = RTMP_OS_NETDEV_GET_PRIV(dev_p); ASSERT(pAdSrc); PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)pAdSrc; PCFG80211_CTRL cfg80211_ctrl = &pAd->cfg80211_ctrl; BOOLEAN isGoOn = FALSE; UINT apidx = 1; struct wifi_dev *Wdev; #endif /* RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE */ if (!wdev) return -EINVAL; #ifdef RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE if (pAd->flg_apcli_init) { DBGPRINT(RT_DEBUG_TRACE, ("ApCli_Close\n")); CFG80211OS_ScanEnd(pAd->pCfg80211_CB, TRUE); // RT_MOD_DEC_USE_COUNT(); ApCli_Close(pAd, dev_p); } DBGPRINT(RT_DEBUG_TRACE, ("%s: ===> %s\n", __FUNCTION__, RTMP_OS_NETDEV_GET_DEVNAME(dev_p))); RTMP_OS_NETDEV_STOP_QUEUE(dev_p); if (INFRA_ON(pAd)) AsicEnableBssSync(pAd,100); else if (ADHOC_ON(pAd)) AsicEnableIbssSync(pAd); else AsicDisableSync(pAd); //VIRTUAL_IF_DOWN(pAd); if (cfg80211_ctrl->dummy_p2p_net_dev) { //iverson if (isGoOn) { Wdev = &pAd->ApCfg.MBSSID[apidx].wdev; wdev_bcn_buf_deinit(pAd, &pAd->ApCfg.MBSSID[apidx].bcn_buf); rtmp_wdev_idx_unreg(pAd, Wdev); Wdev->if_dev = NULL; } else if (pAd->flg_apcli_init) { Wdev = &pAd->ApCfg.ApCliTab[MAIN_MBSSID].wdev; OPSTATUS_CLEAR_FLAG(pAd, fOP_AP_STATUS_MEDIA_STATE_CONNECTED); cfg80211_disconnected(dev_p, 0, NULL, 0, GFP_KERNEL); CFG80211OS_ScanEnd(pAd->pCfg80211_CB, TRUE); NdisZeroMemory(pAd->ApCfg.ApCliTab[MAIN_MBSSID].CfgApCliBssid, MAC_ADDR_LEN); // RtmpOSNetDevDetach(dev_p); rtmp_wdev_idx_unreg(pAd, Wdev); pAd->flg_apcli_init = FALSE; // Wdev->if_dev = NULL; } } AsicSetBssid(pAd, pAd->cfg80211_ctrl.P2PCurrentAddress, 0x1); AsicSetBssid(pAd, pAd->CurrentAddress, 0x0); #endif /* RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE */ wdev->wiphy->interface_modes = (wdev->wiphy->interface_modes) & (~(BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)) | BIT(RT_CMD_80211_IFTYPE_P2P_DEVICE) #endif /* LINUX_VERSION_CODE: 3.7.0 */ )); #ifdef RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE RT_MOD_DEC_USE_COUNT(); #endif /* RT_CFG80211_P2P_STATIC_CONCURRENT_DEVICE */ return 0; }
INT scan_ch_restore(RTMP_ADAPTER *pAd, UCHAR OpMode) { INT bw, ch; if (pAd->CommonCfg.BBPCurrentBW != pAd->hw_cfg.bbp_bw) rtmp_bbp_set_bw(pAd, pAd->hw_cfg.bbp_bw); if (pAd->hw_cfg.bbp_bw == BW_80) ch = pAd->CommonCfg.vht_cent_ch; else if (pAd->hw_cfg.bbp_bw == BW_40) ch = pAd->CommonCfg.CentralChannel; else ch = pAd->CommonCfg.Channel; ASSERT((ch != 0)); AsicSwitchChannel(pAd, ch, FALSE); AsicLockChannel(pAd, ch); switch(pAd->CommonCfg.BBPCurrentBW) { case BW_80: bw = 80; break; case BW_40: bw = 40; break; case BW_10: bw = 10; break; case BW_20: default: bw =20; break; } DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to %dMHz channel %d, Total BSS[%02d]\n", bw, ch, pAd->ScanTab.BssNr)); #ifdef CONFIG_AP_SUPPORT if (OpMode == OPMODE_AP) { #ifdef APCLI_SUPPORT #ifdef APCLI_AUTO_CONNECT_SUPPORT if (pAd->ApCfg.ApCliAutoConnectRunning == TRUE) { if (!ApCliAutoConnectExec(pAd)) { DBGPRINT(RT_DEBUG_ERROR, ("Error in %s\n", __FUNCTION__)); } } #endif /* APCLI_AUTO_CONNECT_SUPPORT */ #endif /* APCLI_SUPPORT */ pAd->Mlme.ApSyncMachine.CurrState = AP_SYNC_IDLE; RTMPResumeMsduTransmission(pAd); /* keep the latest scan channel, could be 0 for scan complete, or other channel */ pAd->ApCfg.LastScanChannel = pAd->MlmeAux.Channel; pAd->ApCfg.ScanChannelCnt=0; /* Suspend scanning and Resume TxData for Fast Scanning */ if ((pAd->MlmeAux.Channel != 0) && (pAd->ApCfg.bImprovedScan)) { pAd->Mlme.ApSyncMachine.CurrState = AP_SCAN_PENDING; DBGPRINT(RT_DEBUG_TRACE, ("bImprovedScan ~~ Get back to send data\n")); } else pAd->ApCfg.bImprovedScan = FALSE; #ifdef CON_WPS if (pAd->conWscStatus != CON_WPS_STATUS_DISABLED) { MlmeEnqueue(pAd, AP_SYNC_STATE_MACHINE, APMT2_MLME_SCAN_COMPLETE, 0, NULL,0 ); RTMP_MLME_HANDLER(pAd); } #endif /* CON_WPS*/ /* iwpriv set auto channel selection*/ /* scanned all channels*/ if (pAd->ApCfg.bAutoChannelAtBootup==TRUE) { pAd->CommonCfg.Channel = SelectBestChannel(pAd, pAd->ApCfg.AutoChannelAlg); pAd->ApCfg.bAutoChannelAtBootup = FALSE; #ifdef DOT11_N_SUPPORT N_ChannelCheck(pAd); #endif /* DOT11_N_SUPPORT */ APStop(pAd); APStartUp(pAd); } if ((pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == TRUE) && RadarChannelCheck(pAd, pAd->CommonCfg.Channel) && pAd->Dot11_H.RDMode != RD_SWITCHING_MODE) { if (pAd->Dot11_H.InServiceMonitorCount) { pAd->Dot11_H.RDMode = RD_NORMAL_MODE; AsicEnableBssSync(pAd); } else { pAd->Dot11_H.RDMode = RD_SILENCE_MODE; } } else { AsicEnableBssSync(pAd); } } #endif /* CONFIG_AP_SUPPORT */ return TRUE; }
/* Before switch channel, driver needs doing channel switch announcement.*/ VOID RadarDetectPeriodic( IN PRTMP_ADAPTER pAd) { #ifdef RT2880 ULONG Value; /* Roger add to fix false detection(long pulse only) in the first 60 seconds */ if (pAd->CommonCfg.W56_debug) { if (pAd->CommonCfg.W56_idx < 300) { pAd->CommonCfg.RadarElectNum = 5; } else if (pAd->CommonCfg.W56_total <= 5000) { if (pAd->CommonCfg.RadarElectNum > 4) pAd->CommonCfg.RadarElectNum--; else pAd->CommonCfg.RadarElectNum = 3; } else if (pAd->CommonCfg.W56_total <= 10000) { if (pAd->CommonCfg.RadarElectNum > 5) pAd->CommonCfg.RadarElectNum--; else pAd->CommonCfg.RadarElectNum = 4; } else if (pAd->CommonCfg.W56_total <= 20000) { if (pAd->CommonCfg.RadarElectNum > 7) pAd->CommonCfg.RadarElectNum--; else if (pAd->CommonCfg.RadarElectNum < 5) pAd->CommonCfg.RadarElectNum++; else pAd->CommonCfg.RadarElectNum = 6; } else if (pAd->CommonCfg.W56_total <= 30000) { if (pAd->CommonCfg.RadarElectNum > 8) pAd->CommonCfg.RadarElectNum--; else if (pAd->CommonCfg.RadarElectNum < 6) pAd->CommonCfg.RadarElectNum++; else pAd->CommonCfg.RadarElectNum = 7; } else if (pAd->CommonCfg.W56_total <= 50000) { if (pAd->CommonCfg.RadarElectNum > 9) pAd->CommonCfg.RadarElectNum--; else if (pAd->CommonCfg.RadarElectNum < 6) pAd->CommonCfg.RadarElectNum++; else pAd->CommonCfg.RadarElectNum = 8; } else if (pAd->CommonCfg.W56_total <= 70000) { if (pAd->CommonCfg.RadarElectNum > 7) pAd->CommonCfg.RadarElectNum--; else if (pAd->CommonCfg.RadarElectNum < 8) pAd->CommonCfg.RadarElectNum++; else pAd->CommonCfg.RadarElectNum = 9; } else { if (pAd->CommonCfg.RadarElectNum < 9) pAd->CommonCfg.RadarElectNum++; else pAd->CommonCfg.RadarElectNum = 10; } } #endif /* RT2880 */ /* need to check channel availability, after switch channel*/ if (pAd->CommonCfg.RadarDetect.RDMode != RD_SILENCE_MODE) return; #ifdef RT2880 #ifdef DFS_SOFTWARE_SUPPORT if (pAd->CommonCfg.dfs_func < HARDWARE_DFS_V1) { /* Roger add to fix false detection(long pulse only) in the first 60 seconds */ if ((pAd->CommonCfg.RadarDetect.RDDurRegion == JAP_W56) || (pAd->CommonCfg.RadarDetect.RDDurRegion == FCC)) { if (pAd->CommonCfg.W56_debug == 0) { RTMP_IO_READ32(pAd, PBF_LIFE_TIMER, &pAd->CommonCfg.W56_hw_1); RTMP_IO_READ32(pAd, CH_TIME_CFG, &Value); RTMP_IO_WRITE32(pAd, CH_TIME_CFG, Value | 1); pAd->CommonCfg.W56_hw_sum = 0; pAd->CommonCfg.W56_idx = 0; pAd->CommonCfg.W56_debug = 1; } } } #endif /* DFS_SOFTWARE_SUPPORT */ #endif /* RT2880 */ /* channel availability check time is 60sec, use 65 for assurance*/ if (pAd->CommonCfg.RadarDetect.RDCount++ > pAd->CommonCfg.RadarDetect.ChMovingTime) { DBGPRINT(RT_DEBUG_TRACE, ("Not found radar signal, start send beacon and radar detection in service monitor\n\n")); #ifdef DFS_SOFTWARE_SUPPORT if (pAd->CommonCfg.dfs_func < HARDWARE_DFS_V1) BbpRadarDetectionStop(pAd); #endif /* DFS_SOFTWARE_SUPPORT */ #ifdef RT2880 pAd->CommonCfg.R66 = pAd->CommonCfg.DFS_R66; #endif /* RT2880 */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef CARRIER_DETECTION_SUPPORT if (pAd->CommonCfg.CarrierDetect.Enable == TRUE) { /* trun on Carrier-Detection. (Carrier-Detect with CTS protection).*/ CARRIER_DETECT_START(pAd, 1); } #endif /* CARRIER_DETECTION_SUPPORT */ } #endif /* CONFIG_AP_SUPPORT */ AsicEnableBssSync(pAd); pAd->CommonCfg.RadarDetect.RDMode = RD_NORMAL_MODE; #ifdef RT2880 #ifdef DFS_SOFTWARE_SUPPORT if (pAd->CommonCfg.dfs_func < HARDWARE_DFS_V1) { if ((pAd->CommonCfg.RadarDetect.RDDurRegion == JAP_W56) || (pAd->CommonCfg.RadarDetect.RDDurRegion == FCC)) { pAd->CommonCfg.W56_debug = 0; RTMP_IO_READ32(pAd, CH_TIME_CFG, &Value); if (Value & 1) { RTMP_IO_WRITE32(pAd, CH_TIME_CFG, Value & ~1); } RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, 114, 0x02); } } #endif /* DFS_SOFTWARE_SUPPORT */ #endif /* RT2880 */ #ifdef CONFIG_AP_SUPPORT IF_DEV_CONFIG_OPMODE_ON_AP(pAd) { #ifdef DFS_SUPPORT #ifdef RTMP_RBUS_SUPPORT #ifdef DFS_HARDWARE_SUPPORT if ((pAd->MACVersion == 0x28720200) && (pAd->CommonCfg.CID == 0x200)) { if (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE) { return; } /*NewRadarDetectionStart(pAd);*/ } else #endif /* DFS_HARDWARE_SUPPORT */ #endif /* RTMP_RBUS_SUPPORT */ { #ifdef DFS_SOFTWARE_SUPPORT if (pAd->CommonCfg.dfs_func < HARDWARE_DFS_V1) AdaptRadarDetection(pAd); /* start radar detection.*/ #endif /* DFS_SOFTWARE_SUPPORT */ } #endif /* DFS_SUPPORT */ } #endif /* CONFIG_AP_SUPPORT */ return; }
static INT scan_ch_restore(RTMP_ADAPTER *pAd, UCHAR OpMode) { INT bw, ch; if (pAd->CommonCfg.BBPCurrentBW != pAd->hw_cfg.bbp_bw) { rtmp_bbp_set_bw(pAd, pAd->hw_cfg.bbp_bw); AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel); ch = pAd->CommonCfg.CentralChannel; } else { AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.Channel); ch = pAd->CommonCfg.Channel; } switch(pAd->CommonCfg.BBPCurrentBW) { case BW_80: bw = 80; break; case BW_40: bw = 40; break; case BW_10: bw = 10; break; case BW_20: default: bw =20; break; } DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to %dMHz channel %d, Total BSS[%02d]\n", bw, ch, pAd->ScanTab.BssNr)); #ifdef CONFIG_AP_SUPPORT if (OpMode == OPMODE_AP) { pAd->Mlme.ApSyncMachine.CurrState = AP_SYNC_IDLE; RTMPResumeMsduTransmission(pAd); /* iwpriv set auto channel selection*/ /* scanned all channels*/ if (pAd->ApCfg.bAutoChannelAtBootup==TRUE) { pAd->CommonCfg.Channel = SelectBestChannel(pAd, pAd->ApCfg.AutoChannelAlg); pAd->ApCfg.bAutoChannelAtBootup = FALSE; #ifdef DOT11_N_SUPPORT N_ChannelCheck(pAd); #endif /* DOT11_N_SUPPORT */ APStop(pAd); APStartUp(pAd); } if (!((pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == TRUE))) AsicEnableBssSync(pAd); } #endif /* CONFIG_AP_SUPPORT */ return TRUE; }
static VOID ApCliTrialConnectRetryTimeout( IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3) { PAPCLI_STRUCT pApCliEntry = (APCLI_STRUCT *)FunctionContext; RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)pApCliEntry->pAd; PULONG pCurrState = &pAd->ApCfg.ApCliTab[pApCliEntry->ifIndex].CtrlCurrState; int i; UCHAR ifIndex = pApCliEntry->ifIndex; UCHAR tempBuf[10] = {}; UCHAR BBPValue; PMAC_TABLE_ENTRY pMacEntry; //PMAC_TABLE_ENTRY pOldRootAp = &pApCliEntry->oldRootAP; pMacEntry = MacTableLookup(pAd, pApCliEntry->MlmeAux.Bssid); //find rootAp that is under connecting if exists in mactable. if (pMacEntry == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("ApCli_SYNC - %s, no CfgApCliBssid in mactable!\n", __func__)); *pCurrState = APCLI_CTRL_DISCONNECTED; pApCliEntry->NewRootApRetryCnt++; if (pApCliEntry->NewRootApRetryCnt >= 10) { DBGPRINT(RT_DEBUG_TRACE, ("%s, RetryCnt:%d, pCurrState = %d, \n", __func__, pApCliEntry->NewRootApRetryCnt, *pCurrState)); pApCliEntry->TrialCh=0; ApCliLinkDown(pAd, ifIndex); MlmeEnqueue(pAd, APCLI_CTRL_STATE_MACHINE, APCLI_CTRL_DISCONNECT_REQ, 0, NULL, ifIndex); NdisZeroMemory(pAd->ApCfg.ApCliTab[ifIndex].CfgSsid, MAX_LEN_OF_SSID);//cleanup CfgSsid. pApCliEntry->CfgSsidLen = 0; pApCliEntry->NewRootApRetryCnt = 0;//cleanup retry count pApCliEntry->Enable = FALSE; } AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, TRUE); AsicEnableBssSync(pAd);//jump back to origin channel, regenerate beacon. return; } if ((pMacEntry->PortSecured == WPA_802_1X_PORT_SECURED) && (*pCurrState == APCLI_CTRL_CONNECTED)) { DBGPRINT(RT_DEBUG_TRACE, ("ApCli_SYNC - %s, new rootAP connected!!\n", __func__)); /* connected to new ap ok, change common channel to new channel */ //AsicSetApCliBssid(pAd, pApCliEntry->ApCliMlmeAux.Bssid, 1); //MacTableDeleteEntry(pAd, pApCliEntry->MacTabWCID, APCLI_ROOT_BSSID_GET(pAd, pApCliEntry->MacTabWCID)); DBGPRINT(RT_DEBUG_TRACE, ("ApCli_SYNC - %s, jump back to origin channel to wait for User's operation!\n", __func__)); AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, TRUE); AsicEnableBssSync(pAd);//jump back to origin channel, regenerate beacon. NdisZeroMemory(pAd->ApCfg.ApCliTab[ifIndex].CfgSsid, MAX_LEN_OF_SSID);//cleanup CfgSsid. pApCliEntry->CfgSsidLen = 0; pApCliEntry->NewRootApRetryCnt = 0;//cleanup retry count pApCliEntry->Enable = FALSE; // sprintf(tempBuf, "%d", pApCliEntry->TrialCh); // DBGPRINT(RT_DEBUG_TRACE, ("Follow new rootAP Switch to channel :%s\n", tempBuf)); // Set_Channel_Proc(pAd, tempBuf);//APStartUp will regenerate beacon. pApCliEntry->TrialCh=0; } else { /* Apcli does not connect to new root ap successfully yet, jump back to origin channel to serve old rootap traffic. re-issue assoc_req to go later. */ //pApCliEntry->MacTabWCID = pOldRootAp->Aid; pApCliEntry->NewRootApRetryCnt++; if (pApCliEntry->NewRootApRetryCnt < 10) RTMPSetTimer(&(pApCliEntry->TrialConnectPhase2Timer), TRIAL_TIMEOUT); else { DBGPRINT(RT_DEBUG_TRACE, ("%s, RetryCnt:%d, pCurrState = %d, \n", __func__, pApCliEntry->NewRootApRetryCnt, *pCurrState)); pApCliEntry->TrialCh=0; MlmeEnqueue(pAd, APCLI_CTRL_STATE_MACHINE, APCLI_CTRL_DISCONNECT_REQ, 0, NULL, ifIndex); NdisZeroMemory(pAd->ApCfg.ApCliTab[ifIndex].CfgSsid, MAX_LEN_OF_SSID);//cleanup CfgSsid. pApCliEntry->CfgSsidLen = 0; pApCliEntry->NewRootApRetryCnt = 0;//cleanup retry count pApCliEntry->Enable = FALSE; ApCliLinkDown(pAd, ifIndex); } AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, TRUE); AsicEnableBssSync(pAd);//jump back to origin channel, regenerate beacon. } return; }
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { PCARRIER_DETECTION_STRUCT pCarrierDetect = &pAd->CommonCfg.CarrierDetect; if (pCarrierDetect->OneSecIntCount < pCarrierDetect->CarrierGoneThreshold) { pCarrierDetect->CD_State = CD_NORMAL; pCarrierDetect->recheck = pCarrierDetect->recheck1; if (pCarrierDetect->Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd); } else { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); } } pCarrierDetect->OneSecIntCount = 0; } #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ #ifdef RT6352 if (IS_RT6352(pAd)) RT6352_AsicAdjustTxPower(pAd); else #endif /* RT6352 */ AsicAdjustTxPower(pAd); /*#endif // WIFI_TEST */ #ifdef THERMAL_PROTECT_SUPPORT thermal_protection(pAd); #endif /* THERMAL_PROTECT_SUPPORT */ RTMP_CHIP_ASIC_TEMPERATURE_COMPENSATION(pAd); /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); #ifdef CONFIG_FPGA_MODE if (pAd->fpga_ctl.fpga_tr_stop) { UINT32 mac_val; /* enable/disable tx/rx*/ RTMP_IO_READ32(pAd, MAC_SYS_CTRL, &mac_val); switch (pAd->fpga_ctl.fpga_tr_stop) { case 3: //stop tx + rx mac_val &= (~0xc); break; case 2: // stop rx mac_val &= (~0x8); break; case 1: // stop tx mac_val &= (~0x4); break; case 4: default: mac_val |= 0x0c; break; } RTMP_IO_WRITE32(pAd, MAC_SYS_CTRL, mac_val); } #endif /* CONFIG_FPGA_MODE */ RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } #ifdef AP_SCAN_SUPPORT AutoChannelSelCheck(pAd); #endif /* AP_SCAN_SUPPORT */ APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1) #ifdef APCLI_AUTO_CONNECT_SUPPORT if (pAd->ApCfg.ApCliAutoConnectChannelSwitching == FALSE) #endif /* APCLI_AUTO_CONNECT_SUPPORT */ ApCliIfUp(pAd); { INT loop; ULONG Now32; #ifdef APCLI_CERT_SUPPORT BOOLEAN IsUseBA = TRUE; #endif /* APCLI_CERT_SUPPORT */ #ifdef MAC_REPEATER_SUPPORT if (pAd->ApCfg.bMACRepeaterEn == TRUE) { #ifdef APCLI_AUTO_CONNECT_SUPPORT RTMPRepeaterReconnectionCheck(pAd); #endif /* APCLI_AUTO_CONNECT_SUPPORT */ } #endif /* MAC_REPEATER_SUPPORT */ NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if (pAd->ApCfg.ApCliTab[loop].bBlockAssoc ==TRUE && pAd->ApCfg.ApCliTab[loop].bBlockAssoc && RTMP_TIME_AFTER(Now32, pAd->ApCfg.ApCliTab[loop].LastMicErrorTime + (60*OS_HZ))) pAd->ApCfg.ApCliTab[loop].bBlockAssoc = FALSE; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MAX_LEN_OF_MAC_TABLE)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); /* WPA MIC error should block association attempt for 60 seconds*/ #ifdef APCLI_CERT_SUPPORT if (pAd->bApCliCertTest == TRUE) { PMAC_TABLE_ENTRY pEntry = &pAd->MacTab.Content[pApCliEntry->MacTabWCID]; struct wifi_dev *wdev = NULL; wdev = &pApCliEntry->wdev; if (pEntry->RXBAbitmap == 0 && pEntry->TXBAbitmap == 0) IsUseBA = FALSE; if( wdev->DesiredHtPhyInfo.bHtEnable && IsUseBA == FALSE ) { EDCA_AC_CFG_STRUC Ac2Cfg, Ac1Cfg; RTMP_IO_READ32(pAd, EDCA_AC2_CFG, &Ac2Cfg.word); RTMP_IO_READ32(pAd, EDCA_AC1_CFG, &Ac1Cfg.word); if ((pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] >= 1000) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] == 0)) { /*5.2.27 T7 */ if (Ac1Cfg.field.Aifsn!=0x1) { Ac1Cfg.field.Aifsn = 0x1; RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word); printk("Change EDCA_AC1_CFG to %x \n", Ac1Cfg.word); } } else if ((pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] == 0) && (pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] < 10)) { /* restore default parameter of BK*/ if (Ac1Cfg.field.Aifsn!=0x7) { Ac1Cfg.field.Aifsn = 0x7; RTMP_IO_WRITE32(pAd, EDCA_AC1_CFG, Ac1Cfg.word); printk("Restore EDCA_AC1_CFG to %x \n", Ac1Cfg.word); } } pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BE] = 0; pAd->RalinkCounters.OneSecOsTxCount[QID_AC_BK] = 0; pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VI] = 0; pAd->RalinkCounters.OneSecOsTxCount[QID_AC_VO] = 0; } } #endif /* APCLI_CERT_SUPPORT */ } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) { AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1) ) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->Dot11_H.InServiceMonitorCount++; if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime) { AsicEnableBssSync(pAd); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; } } #endif /* !DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ #ifdef APCLI_SUPPORT #ifdef DOT11_N_SUPPORT #ifdef DOT11N_DRAFT3 #ifdef APCLI_CERT_SUPPORT /* Perform 20/40 BSS COEX scan every Dot11BssWidthTriggerScanInt */ if (APCLI_IF_UP_CHECK(pAd, 0) && (pAd->bApCliCertTest == TRUE)) { if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SCAN_2040)) && (pAd->CommonCfg.Dot11BssWidthTriggerScanInt != 0) && ((pAd->Mlme.OneSecPeriodicRound % pAd->CommonCfg.Dot11BssWidthTriggerScanInt) == (pAd->CommonCfg.Dot11BssWidthTriggerScanInt-1))) { DBGPRINT(RT_DEBUG_TRACE, ("MMCHK - LastOneSecTotalTxCount/LastOneSecRxOkDataCnt = %d/%d \n", pAd->RalinkCounters.LastOneSecTotalTxCount, pAd->RalinkCounters.LastOneSecRxOkDataCnt)); /* Check last scan time at least 30 seconds from now. */ /* Check traffic is less than about 1.5~2Mbps.*/ /* it might cause data lost if we enqueue scanning.*/ /* This criteria needs to be considered*/ if ((pAd->RalinkCounters.LastOneSecTotalTxCount < 70) && (pAd->RalinkCounters.LastOneSecRxOkDataCnt < 70) /*&& ((pAd->StaCfg.LastScanTime + 10 * OS_HZ) < pAd->Mlme.Now32) */) { MLME_SCAN_REQ_STRUCT ScanReq; /* Fill out stuff for scan request and kick to scan*/ ScanParmFill(pAd, &ScanReq, ZeroSsid, 0, BSS_ANY, SCAN_2040_BSS_COEXIST); /* Before scan, reset trigger event table. */ TriEventInit(pAd); MlmeEnqueue(pAd, AP_SYNC_STATE_MACHINE, APMT2_MLME_SCAN_REQ, sizeof(MLME_SCAN_REQ_STRUCT), &ScanReq, 0); /* Set InfoReq = 1, So after scan , alwats sebd 20/40 Coexistence frame to AP*/ pAd->CommonCfg.BSSCoexist2040.field.InfoReq = 1; RTMP_MLME_HANDLER(pAd); } DBGPRINT(RT_DEBUG_TRACE, (" LastOneSecTotalTxCount/LastOneSecRxOkDataCnt = %d/%d \n", pAd->RalinkCounters.LastOneSecTotalTxCount, pAd->RalinkCounters.LastOneSecRxOkDataCnt)); } } #endif /* APCLI_CERT_SUPPORT */ #endif /* DOT11N_DRAFT3 */ #endif /* DOT11_N_SUPPORT */ #endif /* APCLI_SUPPORT */ }
static INT scan_ch_restore(RTMP_ADAPTER *pAd, UCHAR OpMode) { #ifdef CONFIG_STA_SUPPORT USHORT Status; #endif /* CONFIG_STA_SUPPORT */ INT bw, ch; if (pAd->CommonCfg.BBPCurrentBW != pAd->hw_cfg.bbp_bw) { rtmp_bbp_set_bw(pAd, pAd->hw_cfg.bbp_bw); AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel); ch = pAd->CommonCfg.CentralChannel; } else { AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE); AsicLockChannel(pAd, pAd->CommonCfg.Channel); ch = pAd->CommonCfg.Channel; } switch(pAd->CommonCfg.BBPCurrentBW) { case BW_80: bw = 80; break; case BW_40: bw = 40; break; case BW_10: bw = 10; break; case BW_20: default: bw =20; break; } DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to %dMHz channel %d, Total BSS[%02d]\n", bw, ch, pAd->ScanTab.BssNr)); #ifdef CONFIG_STA_SUPPORT if (OpMode == OPMODE_STA) { /* If all peer Ad-hoc clients leave, driver would do LinkDown and LinkUp. In LinkUp, CommonCfg.Ssid would copy SSID from MlmeAux. To prevent SSID is zero or wrong in Beacon, need to recover MlmeAux.SSID here. */ if (ADHOC_ON(pAd)) { NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID); pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen; NdisMoveMemory(pAd->MlmeAux.Ssid, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen); } /* To prevent data lost. Send an NULL data with turned PSM bit on to current associated AP before SCAN progress. Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done */ if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd))) { RTMPSendNullFrame(pAd, pAd->CommonCfg.TxRate, (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) ? TRUE:FALSE), pAd->CommonCfg.bAPSDForcePowerSave ? PWR_SAVE : pAd->StaCfg.Psm); DBGPRINT(RT_DEBUG_TRACE, ("%s -- Send null frame\n", __FUNCTION__)); } #ifdef RT_CFG80211_SUPPORT if (pAd->ApCfg.ApCliTab[MAIN_MBSSID].Valid && RTMP_CFG80211_VIF_P2P_CLI_ON(pAd)) { DBGPRINT(RT_DEBUG_TRACE, ("CFG80211_NULL: PWR_ACTIVE SCAN_END\n")); RT_CFG80211_P2P_CLI_SEND_NULL_FRAME(pAd, PWR_ACTIVE); } #endif /* RT_CFG80211_SUPPORT */ /* keep the latest scan channel, could be 0 for scan complete, or other channel*/ pAd->StaCfg.LastScanChannel = pAd->MlmeAux.Channel; pAd->StaCfg.ScanChannelCnt = 0; /* Suspend scanning and Resume TxData for Fast Scanning*/ if ((pAd->MlmeAux.Channel != 0) && (pAd->StaCfg.bImprovedScan)) /* it is scan pending*/ { pAd->Mlme.SyncMachine.CurrState = SCAN_PENDING; Status = MLME_SUCCESS; DBGPRINT(RT_DEBUG_WARN, ("bFastRoamingScan ~~~ Get back to send data ~~~\n")); RTMPResumeMsduTransmission(pAd); } else { pAd->StaCfg.BssNr = pAd->ScanTab.BssNr; pAd->StaCfg.bImprovedScan = FALSE; pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE; Status = MLME_SUCCESS; MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status, 0); RTMP_MLME_HANDLER(pAd); } } #endif /* CONFIG_STA_SUPPORT */ #ifdef CONFIG_AP_SUPPORT if (OpMode == OPMODE_AP) { #ifdef P2P_APCLI_SUPPORT /* P2P CLIENT in WSC Scan or Re-Connect scanning. */ if (P2P_CLI_ON(pAd) && (ApScanRunning(pAd) == TRUE)) { /*MlmeEnqueue(pAd, APCLI_CTRL_STATE_MACHINE, APCLI_CTRL_JOIN_REQ_TIMEOUT, 0, NULL, 0);*/ DBGPRINT(RT_DEBUG_INFO, ("%s:: Scan Done! reset APCLI CTRL State Machine!\n", __FUNCTION__)); pAd->ApCfg.ApCliTab[0].CtrlCurrState = APCLI_CTRL_DISCONNECTED; } #endif /* P2P_APCLI_SUPPORT */ pAd->Mlme.ApSyncMachine.CurrState = AP_SYNC_IDLE; RTMPResumeMsduTransmission(pAd); /* iwpriv set auto channel selection*/ /* scanned all channels*/ if (pAd->ApCfg.bAutoChannelAtBootup==TRUE) { pAd->CommonCfg.Channel = SelectBestChannel(pAd, pAd->ApCfg.AutoChannelAlg); pAd->ApCfg.bAutoChannelAtBootup = FALSE; #ifdef DOT11_N_SUPPORT N_ChannelCheck(pAd); #endif /* DOT11_N_SUPPORT */ APStop(pAd); APStartUp(pAd); } if (!((pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == TRUE))) AsicEnableBssSync(pAd); } #endif /* CONFIG_AP_SUPPORT */ return TRUE; }
/* ========================================================================== Description: This routine is executed every second - 1. Decide the overall channel quality 2. Check if need to upgrade the TX rate to any client 3. perform MAC table maintenance, including ageout no-traffic clients, and release packet buffer in PSQ is fail to TX in time. ========================================================================== */ VOID APMlmePeriodicExec( PRTMP_ADAPTER pAd) { /* Reqeust by David 2005/05/12 It make sense to disable Adjust Tx Power on AP mode, since we can't take care all of the client's situation ToDo: need to verify compatibility issue with WiFi product. */ #ifdef CARRIER_DETECTION_SUPPORT if (isCarrierDetectExist(pAd) == TRUE) { PCARRIER_DETECTION_STRUCT pCarrierDetect = &pAd->CommonCfg.CarrierDetect; if (pCarrierDetect->OneSecIntCount < pCarrierDetect->CarrierGoneThreshold) { pCarrierDetect->CD_State = CD_NORMAL; pCarrierDetect->recheck = pCarrierDetect->recheck1; if (pCarrierDetect->Debug != RT_DEBUG_TRACE) { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); /* start all TX actions. */ APMakeAllBssBeacon(pAd); APUpdateAllBeaconFrame(pAd); AsicEnableBssSync(pAd, pAd->CommonCfg.BeaconPeriod); } else { DBGPRINT(RT_DEBUG_TRACE, ("Carrier gone\n")); } } pCarrierDetect->OneSecIntCount = 0; } #endif /* CARRIER_DETECTION_SUPPORT */ RTMP_CHIP_HIGH_POWER_TUNING(pAd, &pAd->ApCfg.RssiSample); /* Disable Adjust Tx Power for WPA WiFi-test. */ /* Because high TX power results in the abnormal disconnection of Intel BG-STA. */ /*#ifndef WIFI_TEST */ /* if (pAd->CommonCfg.bWiFiTest == FALSE) */ /* for SmartBit 64-byte stream test */ /* removed based on the decision of Ralink congress at 2011/7/06 */ /* if (pAd->MacTab.Size > 0) */ RTMP_CHIP_ASIC_ADJUST_TX_POWER(pAd); /*#endif // WIFI_TEST */ RTMP_CHIP_ASIC_TEMPERATURE_COMPENSATION(pAd); /* walk through MAC table, see if switching TX rate is required */ /* MAC table maintenance */ if (pAd->Mlme.PeriodicRound % MLME_TASK_EXEC_MULTIPLE == 0) { /* one second timer */ MacTableMaintenance(pAd); #ifdef CONFIG_FPGA_MODE if (pAd->fpga_ctl.fpga_tr_stop) { INT enable = FALSE, ctrl_type; /* enable/disable tx/rx*/ switch (pAd->fpga_ctl.fpga_tr_stop) { case 3: //stop tx + rx ctrl_type = ASIC_MAC_TXRX; break; case 2: // stop rx ctrl_type = ASIC_MAC_RX; break; case 1: // stop tx ctrl_type = ASIC_MAC_TX; break; case 4: default: enable = TRUE; ctrl_type = ASIC_MAC_TXRX; break; } AsicSetMacTxRx(pAd, ctrl_type, enable); } #endif /* CONFIG_FPGA_MODE */ RTMPMaintainPMKIDCache(pAd); #ifdef WDS_SUPPORT WdsTableMaintenance(pAd); #endif /* WDS_SUPPORT */ #ifdef CLIENT_WDS CliWds_ProxyTabMaintain(pAd); #endif /* CLIENT_WDS */ } #ifdef AP_SCAN_SUPPORT AutoChannelSelCheck(pAd); #endif /* AP_SCAN_SUPPORT */ APUpdateCapabilityAndErpIe(pAd); #ifdef APCLI_SUPPORT if (pAd->Mlme.OneSecPeriodicRound % 2 == 0) ApCliIfMonitor(pAd); if (pAd->Mlme.OneSecPeriodicRound % 2 == 1 #ifdef APCLI_AUTO_CONNECT_SUPPORT && (pAd->ApCfg.ApCliAutoConnectChannelSwitching == FALSE) #endif /* APCLI_AUTO_CONNECT_SUPPORT */ ) { ApCliIfUp(pAd); } { INT loop; ULONG Now32; #ifdef MAC_REPEATER_SUPPORT if (pAd->ApCfg.bMACRepeaterEn) { RTMPRepeaterReconnectionCheck(pAd); } #endif /* MAC_REPEATER_SUPPORT */ NdisGetSystemUpTime(&Now32); for (loop = 0; loop < MAX_APCLI_NUM; loop++) { PAPCLI_STRUCT pApCliEntry = &pAd->ApCfg.ApCliTab[loop]; if ((pApCliEntry->Valid == TRUE) && (pApCliEntry->MacTabWCID < MAX_LEN_OF_MAC_TABLE)) { /* update channel quality for Roaming and UI LinkQuality display */ MlmeCalculateChannelQuality(pAd, &pAd->MacTab.Content[pApCliEntry->MacTabWCID], Now32); } } } #endif /* APCLI_SUPPORT */ #ifdef DOT11_N_SUPPORT if (pAd->CommonCfg.bHTProtect) { /*APUpdateCapabilityAndErpIe(pAd); */ APUpdateOperationMode(pAd); if (pAd->CommonCfg.IOTestParm.bRTSLongProtOn == FALSE) AsicUpdateProtect(pAd, (USHORT)pAd->CommonCfg.AddHTInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, pAd->MacTab.fAnyStationNonGF); } #endif /* DOT11_N_SUPPORT */ #ifdef A_BAND_SUPPORT if ( (pAd->CommonCfg.Channel > 14) && (pAd->CommonCfg.bIEEE80211H == 1)) { #ifdef DFS_SUPPORT ApRadarDetectPeriodic(pAd); #else pAd->Dot11_H.InServiceMonitorCount++; if (pAd->Dot11_H.RDMode == RD_SILENCE_MODE) { if (pAd->Dot11_H.RDCount++ > pAd->Dot11_H.ChMovingTime) { AsicEnableBssSync(pAd, pAd->CommonCfg.BeaconPeriod); pAd->Dot11_H.RDMode = RD_NORMAL_MODE; } } #endif /* !DFS_SUPPORT */ } #endif /* A_BAND_SUPPORT */ }