void LeaveAllPowerSaveMode(struct adapter *Adapter) { struct dvobj_priv *dvobj = adapter_to_dvobj(Adapter); u8 enqueue = 0; int n_assoc_iface = 0; if (!Adapter->bup) { DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n", FUNC_ADPT_ARG(Adapter), Adapter->bup); return; } if (Adapter->bSurpriseRemoved) { DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n", FUNC_ADPT_ARG(Adapter), Adapter->bSurpriseRemoved); return; } if (check_fwstate(&(dvobj->padapters->mlmepriv), WIFI_ASOC_STATE)) n_assoc_iface++; if (n_assoc_iface) { /* connect */ enqueue = 1; rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue); LPS_Leave_check(Adapter); } else { if (adapter_to_pwrctl(Adapter)->rf_pwrstate == rf_off) { if (false == ips_leave(Adapter)) DBG_871X("======> ips_leave fail.............\n"); } } }
void LeaveAllPowerSaveModeDirect(struct adapter *Adapter) { struct adapter *pri_padapter = GET_PRIMARY_ADAPTER(Adapter); struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(Adapter); DBG_871X("%s.....\n", __func__); if (true == Adapter->bSurpriseRemoved) { DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n", FUNC_ADPT_ARG(Adapter), Adapter->bSurpriseRemoved); return; } if ((check_fwstate(pmlmepriv, _FW_LINKED) == true)) { /* connect */ if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { DBG_871X("%s: Driver Already Leave LPS\n", __func__); return; } down(&pwrpriv->lock); rtw_set_rpwm(Adapter, PS_STATE_S4); up(&pwrpriv->lock); rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0); } else{ if (pwrpriv->rf_pwrstate == rf_off) if (false == ips_leave(pri_padapter)) DBG_871X("======> ips_leave fail.............\n"); } }
void rtl8723b_silentreset_for_specific_platform(_adapter *padapter) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; _irqL irqL; #ifdef DBG_CONFIG_ERROR_RESET DBG_871X("%s\n", __FUNCTION__); psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; if (!rtw_netif_queue_stopped(padapter->pnetdev)) rtw_netif_stop_queue(padapter->pnetdev); rtw_cancel_all_timer(padapter); tasklet_kill(&pxmitpriv->xmit_tasklet); _enter_critical_mutex(&psrtpriv->silentreset_mutex, &irqL); psrtpriv->silent_reset_inprogress = _TRUE; pwrpriv->change_rfpwrstate = rf_off; #ifdef CONFIG_IPS ips_enter(padapter); ips_leave(padapter); #endif if(check_fwstate(pmlmepriv, _FW_LINKED)== _TRUE) { _restore_network_status(padapter); _restore_security_setting(padapter); } _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING); psrtpriv->silent_reset_inprogress = _FALSE; _exit_critical_mutex(&psrtpriv->silentreset_mutex, &irqL); tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000); if (netif_queue_stopped(padapter->pnetdev)) netif_wake_queue(padapter->pnetdev); #endif }
void rtl8192c_silentreset_for_specific_platform(_adapter *padapter) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; _irqL irqL; psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; if (!netif_queue_stopped(padapter->pnetdev)) netif_stop_queue(padapter->pnetdev); rtw_cancel_all_timer(padapter); tasklet_kill(&pxmitpriv->xmit_tasklet); _enter_critical_mutex(&psrtpriv->silentreset_mutex, &irqL); psrtpriv->silent_reset_inprogress = _TRUE; pwrpriv->change_rfpwrstate = rf_off; ips_enter(padapter); ips_leave(padapter); if(check_fwstate(pmlmepriv, _FW_LINKED)== _TRUE) { _restore_network_status(padapter); _restore_security_setting(padapter); } if(pmlmepriv->fw_state & _FW_UNDER_SURVEY) pmlmepriv->fw_state ^= _FW_UNDER_SURVEY; if(pmlmepriv->fw_state & _FW_UNDER_LINKING) pmlmepriv->fw_state ^= _FW_UNDER_LINKING; psrtpriv->silent_reset_inprogress = _FALSE; _exit_critical_mutex(&psrtpriv->silentreset_mutex, &irqL); tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000); if (netif_queue_stopped(padapter->pnetdev)) netif_wake_queue(padapter->pnetdev); }
void sreset_reset(_adapter *padapter) { #ifdef DBG_CONFIG_ERROR_RESET HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; _irqL irqL; u32 start = rtw_get_current_time(); DBG_871X("%s\n", __FUNCTION__); psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; _enter_critical_mutex(&psrtpriv->silentreset_mutex, &irqL); psrtpriv->silent_reset_inprogress = _TRUE; pwrpriv->change_rfpwrstate = rf_off; sreset_stop_adapter(padapter); #ifdef CONFIG_CONCURRENT_MODE sreset_stop_adapter(padapter->pbuddy_adapter); #endif #ifdef CONFIG_IPS ips_enter(padapter); ips_leave(padapter); #endif sreset_start_adapter(padapter); #ifdef CONFIG_CONCURRENT_MODE sreset_start_adapter(padapter->pbuddy_adapter); #endif psrtpriv->silent_reset_inprogress = _FALSE; _exit_critical_mutex(&psrtpriv->silentreset_mutex, &irqL); DBG_871X("%s done in %d ms\n", __FUNCTION__, rtw_get_passing_time_ms(start)); #endif }
int _rtw_pwr_wakeup(_adapter *padapter, u32 ips_deffer_ms, const char *caller) { struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj); struct mlme_priv *pmlmepriv; int ret = _SUCCESS; unsigned long start = jiffies; unsigned long deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); /* for LPS */ LeaveAllPowerSaveMode(padapter); /* IPS still bound with primary adapter */ padapter = GET_PRIMARY_ADAPTER(padapter); pmlmepriv = &padapter->mlmepriv; if (time_before(pwrpriv->ips_deny_time, deny_time)) pwrpriv->ips_deny_time = deny_time; if (pwrpriv->ps_processing) { DBG_871X("%s wait ps_processing...\n", __func__); while (pwrpriv->ps_processing && jiffies_to_msecs(jiffies - start) <= 3000) msleep(10); if (pwrpriv->ps_processing) DBG_871X("%s wait ps_processing timeout\n", __func__); else DBG_871X("%s wait ps_processing done\n", __func__); } if (pwrpriv->bInternalAutoSuspend == false && pwrpriv->bInSuspend) { DBG_871X("%s wait bInSuspend...\n", __func__); while (pwrpriv->bInSuspend && jiffies_to_msecs(jiffies - start) <= 3000 ) { msleep(10); } if (pwrpriv->bInSuspend) DBG_871X("%s wait bInSuspend timeout\n", __func__); else DBG_871X("%s wait bInSuspend done\n", __func__); } /* System suspend is not allowed to wakeup */ if ((pwrpriv->bInternalAutoSuspend == false) && (true == pwrpriv->bInSuspend)){ ret = _FAIL; goto exit; } /* block??? */ if ((pwrpriv->bInternalAutoSuspend == true) && (padapter->net_closed == true)) { ret = _FAIL; goto exit; } /* I think this should be check in IPS, LPS, autosuspend functions... */ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { ret = _SUCCESS; goto exit; } if (rf_off == pwrpriv->rf_pwrstate) { { DBG_8192C("%s call ips_leave....\n", __FUNCTION__); if (_FAIL == ips_leave(padapter)) { DBG_8192C("======> ips_leave fail.............\n"); ret = _FAIL; goto exit; } } } /* TODO: the following checking need to be merged... */ if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed ){ DBG_8192C("%s: bDriverStopped =%d, bup =%d, hw_init_completed =%u\n" , caller , padapter->bDriverStopped , padapter->bup , padapter->hw_init_completed); ret = false; goto exit; } exit: deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); if (time_before(pwrpriv->ips_deny_time, deny_time)) pwrpriv->ips_deny_time = deny_time; return ret; }
int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *caller) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; unsigned long expires; unsigned long start; int ret = _SUCCESS; expires = jiffies + msecs_to_jiffies(ips_deffer_ms); if (time_before(pwrpriv->ips_deny_time, expires)) pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); start = jiffies; if (pwrpriv->ps_processing) { DBG_88E("%s wait ps_processing...\n", __func__); while (pwrpriv->ps_processing && jiffies_to_msecs(jiffies - start) <= 3000) usleep_range(1000, 3000); if (pwrpriv->ps_processing) DBG_88E("%s wait ps_processing timeout\n", __func__); else DBG_88E("%s wait ps_processing done\n", __func__); } /* System suspend is not allowed to wakeup */ if ((!pwrpriv->bInternalAutoSuspend) && (pwrpriv->bInSuspend)) { ret = _FAIL; goto exit; } /* block??? */ if ((pwrpriv->bInternalAutoSuspend) && (padapter->net_closed)) { ret = _FAIL; goto exit; } /* I think this should be check in IPS, LPS, autosuspend functions... */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { ret = _SUCCESS; goto exit; } if (rf_off == pwrpriv->rf_pwrstate) { DBG_88E("%s call ips_leave....\n", __func__); if (_FAIL == ips_leave(padapter)) { DBG_88E("======> ips_leave fail.............\n"); ret = _FAIL; goto exit; } } /* TODO: the following checking need to be merged... */ if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed) { DBG_88E("%s: bDriverStopped=%d, bup=%d, hw_init_completed =%u\n" , caller , padapter->bDriverStopped , padapter->bup , padapter->hw_init_completed); ret = false; goto exit; } exit: expires = jiffies + msecs_to_jiffies(ips_deffer_ms); if (time_before(pwrpriv->ips_deny_time, expires)) pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); return ret; }
/* * rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend * @adapter: pointer to _adapter structure * @ips_deffer_ms: the ms wiil prevent from falling into IPS after wakeup * Return _SUCCESS or _FAIL */ int _rtw_pwr_wakeup(struct rtw_adapter *padapter, u32 ips_deffer_ms, const char *caller) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int ret = _SUCCESS; u32 start = rtw_get_current_time(); #ifdef CONFIG_CONCURRENT_MODE if (padapter->pbuddy_adapter) LeaveAllPowerSaveMode(padapter->pbuddy_adapter); if ((padapter->isprimary == false) && padapter->pbuddy_adapter) { padapter = padapter->pbuddy_adapter; pwrpriv = &padapter->pwrctrlpriv; pmlmepriv = &padapter->mlmepriv; } #endif if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms)) pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms); if (pwrpriv->ps_processing) { DBG_8192D("%s wait ps_processing...\n", __func__); while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000) rtw_msleep_os(10); if (pwrpriv->ps_processing) DBG_8192D("%s wait ps_processing timeout\n", __func__); else DBG_8192D("%s wait ps_processing done\n", __func__); } if (pwrpriv->bInternalAutoSuspend == false && pwrpriv->bInSuspend) { DBG_8192D("%s wait bInSuspend...\n", __func__); while (pwrpriv->bInSuspend && ((rtw_get_passing_time_ms(start) <= 3000 && !rtw_is_do_late_resume(pwrpriv)) || (rtw_get_passing_time_ms(start) <= 500 && rtw_is_do_late_resume(pwrpriv)))) { rtw_msleep_os(10); } if (pwrpriv->bInSuspend) DBG_8192D("%s wait bInSuspend timeout\n", __func__); else DBG_8192D("%s wait bInSuspend done\n", __func__); } /* System suspend is not allowed to wakeup */ if ((pwrpriv->bInternalAutoSuspend == false) && (true == pwrpriv->bInSuspend)) { ret = _FAIL; goto exit; } /* block??? */ if ((pwrpriv->bInternalAutoSuspend == true) && (padapter->net_closed == true)) { ret = _FAIL; goto exit; } /* I think this should be check in IPS, LPS, autosuspend functions... */ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { ret = _SUCCESS; goto exit; } if (rf_off == pwrpriv->rf_pwrstate) { #ifdef CONFIG_AUTOSUSPEND if (pwrpriv->brfoffbyhw == true) { DBG_8192D("hw still in rf_off state ...........\n"); ret = _FAIL; goto exit; } else if (padapter->registrypriv.usbss_enable) { DBG_8192D("%s call autoresume_enter....\n", __func__); if (_FAIL == autoresume_enter(padapter)) { DBG_8192D ("======> autoresume fail.............\n"); ret = _FAIL; goto exit; } } else #endif { #ifdef CONFIG_IPS DBG_8192D("%s call ips_leave....\n", __func__); if (_FAIL == ips_leave(padapter)) { DBG_8192D ("======> ips_leave fail.............\n"); ret = _FAIL; goto exit; } #endif } } /* TODO: the following checking need to be merged... */ if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed) { DBG_8192D ("%s: bDriverStopped=%d, bup=%d, hw_init_completed=%u\n", caller, padapter->bDriverStopped, padapter->bup, padapter->hw_init_completed); ret = false; goto exit; } exit: if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms)) pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms); return ret; }
// // Description: Leave all power save mode: LPS, FwLPS, IPS if needed. // Move code to function by tynli. 2010.03.26. // void LeaveAllPowerSaveMode(IN PADAPTER Adapter) { struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); u32 LPSLeaveTimeOut = 10000; //u32 IPSLeaveTimeOut = 10000; _func_enter_; //DBG_8192C("%s.....\n",__FUNCTION__); if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) { //connect #ifdef CONFIG_P2P p2p_ps_wk_cmd(Adapter, P2P_PS_DISABLE, 0); #endif #ifdef CONFIG_LPS //DBG_8192C("==> leave LPS.......\n"); LPS_Leave(Adapter); if (Adapter->pwrctrlpriv.bLeisurePs) { BOOLEAN bAwake = _TRUE; Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bAwake)); while(!bAwake) { rtw_usleep_os(100); LPSLeaveTimeOut--; if(LPSLeaveTimeOut <= 0) { DBG_8192C("Wait for FW LPS leave too long!!! LPSLeaveTimeOut = %d\n", LPSLeaveTimeOut ); break; } Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bAwake)); } } #endif } else { if(Adapter->pwrctrlpriv.current_rfpwrstate== rf_off) { DBG_8192C("==> leave IPS.......\n"); #ifdef CONFIG_AUTOSUSPEND if(Adapter->registrypriv.usbss_enable) { #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35)) usb_disable_autosuspend(Adapter->dvobjpriv.pusbdev); #elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,22) && LINUX_VERSION_CODE<=KERNEL_VERSION(2,6,34)) Adapter->dvobjpriv.pusbdev->autosuspend_disabled = Adapter->bDisableAutosuspend;//autosuspend disabled by the user #endif } else #endif { #ifdef CONFIG_IPS if(_FALSE == ips_leave(Adapter)) { DBG_8192C("======> ips_leave fail.............\n"); } #endif } } } _func_exit_; }