void traffic_check_for_leave_lps(PADAPTER padapter, u8 tx, u32 tx_packets) { static unsigned long start_time = 0; static u32 xmit_cnt = 0; u8 bLeaveLPS = false; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (tx) /* from tx */ { xmit_cnt += tx_packets; if (start_time == 0) start_time = jiffies; if (jiffies_to_msecs(jiffies - start_time) > 2000) /* 2 sec == watch dog timer */ { if (xmit_cnt > 8) { if ((adapter_to_pwrctl(padapter)->bLeisurePs) && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) && (rtw_btcoex_IsBtControlLps(padapter) == false) ) { DBG_871X("leave lps via Tx = %d\n", xmit_cnt); bLeaveLPS = true; } } start_time = jiffies; xmit_cnt = 0; } } else /* from rx path */ { if (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 4/*2*/) { if ((adapter_to_pwrctl(padapter)->bLeisurePs) && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) && (rtw_btcoex_IsBtControlLps(padapter) == false) ) { DBG_871X("leave lps via Rx = %d\n", pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); bLeaveLPS = true; } } } if (bLeaveLPS) { /* DBG_871X("leave lps via %s, Tx = %d, Rx = %d \n", tx?"Tx":"Rx", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */ /* rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1); */ rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, tx?0:1); } }
static bool rtw_pwr_unassociated_idle(_adapter *adapter) { _adapter *buddy = adapter->pbuddy_adapter; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); struct xmit_priv *pxmit_priv = &adapter->xmitpriv; bool ret = false; if (adapter_to_pwrctl(adapter)->bpower_saving ==true) { /* DBG_871X("%s: already in LPS or IPS mode\n", __func__); */ goto exit; } if (time_before(jiffies, adapter_to_pwrctl(adapter)->ips_deny_time)) { /* DBG_871X("%s ips_deny_time\n", __func__); */ goto exit; } if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || check_fwstate(pmlmepriv, WIFI_AP_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) ) { goto exit; } /* consider buddy, if exist */ if (buddy) { struct mlme_priv *b_pmlmepriv = &(buddy->mlmepriv); if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || check_fwstate(b_pmlmepriv, WIFI_AP_STATE) || check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) ) { goto exit; } } if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF || pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) { DBG_871X_LEVEL(_drv_always_, "There are some pkts to transmit\n"); DBG_871X_LEVEL(_drv_always_, "free_xmitbuf_cnt: %d, free_xmit_extbuf_cnt: %d\n", pxmit_priv->free_xmitbuf_cnt, pxmit_priv->free_xmit_extbuf_cnt); goto exit; } ret = true; exit: return ret; }
/* * Do deinit job corresponding to netdev_open() */ void rtw_dev_unload(PADAPTER padapter) { struct net_device *pnetdev = (struct net_device*)padapter->pnetdev; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+rtw_dev_unload\n")); padapter->bDriverStopped = _TRUE; #ifdef CONFIG_XMIT_ACK if (padapter->xmitpriv.ack_tx) rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP); #endif if (padapter->bup == _TRUE) { #if 0 if (padapter->intf_stop) padapter->intf_stop(padapter); #else gspi_intf_stop(padapter); #endif RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("@ rtw_dev_unload: stop intf complete!\n")); if (!adapter_to_pwrctl(padapter)->bInternalAutoSuspend) rtw_stop_drv_threads(padapter); RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("@ rtw_dev_unload: stop thread complete!\n")); if (padapter->bSurpriseRemoved == _FALSE) { #ifdef CONFIG_WOWLAN if (adapter_to_pwrctl(padapter)->bSupportRemoteWakeup == _TRUE) { DBG_871X("%s bSupportRemoteWakeup==_TRUE do not run rtw_hal_deinit()\n",__FUNCTION__); } else #endif { rtw_hal_deinit(padapter); } padapter->bSurpriseRemoved = _TRUE; } RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("@ rtw_dev_unload: deinit hal complelt!\n")); padapter->bup = _FALSE; } else { RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("rtw_dev_unload: bup==_FALSE\n")); } RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("-rtw_dev_unload\n")); }
int rtw_android_pno_enable(struct net_device *net, int pno_enable) { _adapter *padapter = (_adapter *)rtw_netdev_priv(net); struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); if (pwrctl) { pwrctl->wowlan_pno_enable = pno_enable; DBG_871X("%s: wowlan_pno_enable: %d\n", __func__, pwrctl->wowlan_pno_enable); if (pwrctl->wowlan_pno_enable == 0) { if (pwrctl->pnlo_info != NULL) { rtw_mfree((u8 *)pwrctl->pnlo_info, sizeof(pno_nlo_info_t)); pwrctl->pnlo_info = NULL; } if (pwrctl->pno_ssid_list != NULL) { rtw_mfree((u8 *)pwrctl->pno_ssid_list, sizeof(pno_ssid_list_t)); pwrctl->pno_ssid_list = NULL; } if (pwrctl->pscan_info != NULL) { rtw_mfree((u8 *)pwrctl->pscan_info, sizeof(pno_scan_info_t)); pwrctl->pscan_info = NULL; } } return 0; } else { return -1; } }
/* * Caller: rtw_xmit_thread * * Check if the fw_pwrstate is okay for xmit. * If not (cpwm is less than S3), then the sub-routine * will raise the cpwm to be greater than or equal to S3. * * Calling Context: Passive * * Return Value: * _SUCCESS rtw_xmit_thread can write fifo/txcmd afterwards. * _FAIL rtw_xmit_thread can not do anything. */ s32 rtw_register_tx_alive(struct adapter *padapter) { s32 res; struct pwrctrl_priv *pwrctrl; u8 pslv; res = _SUCCESS; pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S2; down(&pwrctrl->lock); register_task_alive(pwrctrl, XMIT_ALIVE); if (pwrctrl->bFwCurrentInPSMode == true) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("rtw_register_tx_alive: cpwm = 0x%02x alives = 0x%08x\n", pwrctrl->cpwm, pwrctrl->alives)); if (pwrctrl->cpwm < pslv) { if (pwrctrl->cpwm < PS_STATE_S2) res = _FAIL; if (pwrctrl->rpwm < pslv) rtw_set_rpwm(padapter, pslv); } } up(&pwrctrl->lock); if (_FAIL == res) if (pwrctrl->cpwm >= PS_STATE_S2) res = _SUCCESS; return res; }
/* * Description: *If task is done, call this func. to power down firmware again. * *Constraint: * 1. this function will request pwrctrl->lock * * Return Value: *none */ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) { struct pwrctrl_priv *pwrctrl; u8 pslv; pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; if ((rtw_btcoex_IsBtDisabled(padapter) == false) && (rtw_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; val8 = rtw_btcoex_LpsVal(padapter); if (val8 & BIT(4)) pslv = PS_STATE_S2; } down(&pwrctrl->lock); unregister_task_alive(pwrctrl, task); if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && (pwrctrl->bFwCurrentInPSMode == true)) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: cpwm = 0x%02x alives = 0x%08x\n", __func__, pwrctrl->cpwm, pwrctrl->alives)); if (pwrctrl->cpwm > pslv) if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0)) rtw_set_rpwm(padapter, pslv); } up(&pwrctrl->lock); }
void LPS_Leave_check( struct adapter *padapter) { struct pwrctrl_priv *pwrpriv; unsigned long start_time; u8 bReady; pwrpriv = adapter_to_pwrctl(padapter); bReady = false; start_time = jiffies; cond_resched(); while (1) { down(&pwrpriv->lock); if ((padapter->bSurpriseRemoved == true) || (padapter->hw_init_completed == false) || (pwrpriv->pwr_mode == PS_MODE_ACTIVE) ) bReady = true; up(&pwrpriv->lock); if (true == bReady) break; if (jiffies_to_msecs(jiffies - start_time) > 100) { DBG_871X("Wait for cpwm event than 100 ms!!!\n"); break; } msleep(1); } }
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 _ips_enter(_adapter * padapter) { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); if (padapter->hw_init_completed == _FALSE) { DBG_871X("%s: hw_init_completed: %d\n", __func__, padapter->hw_init_completed); return; } pwrpriv->bips_processing = _TRUE; // syn ips_mode with request pwrpriv->ips_mode = pwrpriv->ips_mode_req; pwrpriv->ips_enter_cnts++; DBG_871X("==>ips_enter cnts:%d\n",pwrpriv->ips_enter_cnts); #ifdef CONFIG_BT_COEXIST BTDM_TurnOffBtCoexistBeforeEnterIPS(padapter); #endif if(rf_off == pwrpriv->change_rfpwrstate ) { pwrpriv->bpower_saving = _TRUE; DBG_871X_LEVEL(_drv_always_, "nolinked power save enter\n"); if(pwrpriv->ips_mode == IPS_LEVEL_2) pwrpriv->bkeepfwalive = _TRUE; rtw_ips_pwr_down(padapter); pwrpriv->rf_pwrstate = rf_off; } pwrpriv->bips_processing = _FALSE; }
/* * Caller:ISR handler... * * This will be called when CPWM interrupt is up. * * using to update cpwn of drv; and drv willl make a decision to up or down pwr level */ void cpwm_int_hdl( PADAPTER padapter, struct reportpwrstate_parm *preportpwrstate) { struct pwrctrl_priv *pwrpriv; pwrpriv = adapter_to_pwrctl(padapter); down(&pwrpriv->lock); if (pwrpriv->rpwm < PS_STATE_S2) { DBG_871X("%s: Redundant CPWM Int. RPWM =0x%02X CPWM =0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); up(&pwrpriv->lock); goto exit; } pwrpriv->cpwm = PS_STATE(preportpwrstate->state); pwrpriv->cpwm_tog = preportpwrstate->state & PS_TOGGLE; if (pwrpriv->cpwm >= PS_STATE_S2) { if (pwrpriv->alives & CMD_ALIVE) up(&padapter->cmdpriv.cmd_queue_sema); if (pwrpriv->alives & XMIT_ALIVE) up(&padapter->xmitpriv.xmit_sema); } up(&pwrpriv->lock); exit: RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("cpwm_int_hdl: cpwm =0x%02x\n", pwrpriv->cpwm)); }
void _ips_enter(_adapter * padapter) { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); pwrpriv->bips_processing = true; /* syn ips_mode with request */ pwrpriv->ips_mode = pwrpriv->ips_mode_req; pwrpriv->ips_enter_cnts++; DBG_871X("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts); if (rf_off == pwrpriv->change_rfpwrstate) { pwrpriv->bpower_saving = true; DBG_871X_LEVEL(_drv_always_, "nolinked power save enter\n"); if (pwrpriv->ips_mode == IPS_LEVEL_2) pwrpriv->bkeepfwalive = true; rtw_ips_pwr_down(padapter); pwrpriv->rf_pwrstate = rf_off; } pwrpriv->bips_processing = false; }
void rtw_init_pwrctrl_priv(PADAPTER padapter) { struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); sema_init(&pwrctrlpriv->lock, 1); sema_init(&pwrctrlpriv->check_32k_lock, 1); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts =0; pwrctrlpriv->ips_leave_cnts =0; pwrctrlpriv->bips_processing = false; pwrctrlpriv->ips_mode = padapter->registrypriv.ips_mode; pwrctrlpriv->ips_mode_req = padapter->registrypriv.ips_mode; pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL; pwrctrlpriv->pwr_state_check_cnts = 0; pwrctrlpriv->bInternalAutoSuspend = false; pwrctrlpriv->bInSuspend = false; pwrctrlpriv->bkeepfwalive = false; pwrctrlpriv->LpsIdleCount = 0; if (padapter->registrypriv.mp_mode == 1) pwrctrlpriv->power_mgnt =PS_MODE_ACTIVE ; else pwrctrlpriv->power_mgnt =padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; pwrctrlpriv->bFwCurrentInPSMode = false; pwrctrlpriv->rpwm = 0; pwrctrlpriv->cpwm = PS_STATE_S4; pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE; pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps; pwrctrlpriv->bcn_ant_mode = 0; pwrctrlpriv->dtim = 0; pwrctrlpriv->tog = 0x80; rtw_hal_set_hwreg(padapter, HW_VAR_SET_RPWM, (u8 *)(&pwrctrlpriv->rpwm)); _init_workitem(&pwrctrlpriv->cpwm_event, cpwm_event_callback, NULL); pwrctrlpriv->brpwmtimeout = false; _init_workitem(&pwrctrlpriv->rpwmtimeoutwi, rpwmtimeout_workitem_callback, NULL); _init_timer(&pwrctrlpriv->pwr_rpwm_timer, padapter->pnetdev, pwr_rpwm_timeout_handler, padapter); rtw_init_timer(&pwrctrlpriv->pwr_state_check_timer, padapter, pwr_state_check_handler); pwrctrlpriv->wowlan_mode = false; pwrctrlpriv->wowlan_ap_mode = false; #ifdef CONFIG_PNO_SUPPORT pwrctrlpriv->pno_inited = false; pwrctrlpriv->pnlo_info = NULL; pwrctrlpriv->pscan_info = NULL; pwrctrlpriv->pno_ssid_list = NULL; pwrctrlpriv->pno_in_resume = true; #endif }
int rtw_pm_set_lps(_adapter *padapter, u8 mode) { int ret = 0; struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); if (mode < PS_MODE_NUM) { if (pwrctrlpriv->power_mgnt !=mode) { if (PS_MODE_ACTIVE == mode) { LeaveAllPowerSaveMode(padapter); } else { pwrctrlpriv->LpsIdleCount = 2; } pwrctrlpriv->power_mgnt = mode; pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; } } else { ret = -EINVAL; } return ret; }
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 rtw_hal_dm_watchdog_in_lps(struct adapter *padapter) { if (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode == true) { if (padapter->HalFunc.hal_dm_watchdog_in_lps) padapter->HalFunc.hal_dm_watchdog_in_lps(padapter); /* this fuction caller is in interrupt context */ } }
int _ips_leave(_adapter * padapter) { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); int result = _SUCCESS; if ((pwrpriv->rf_pwrstate == rf_off) &&(!pwrpriv->bips_processing)) { pwrpriv->bips_processing = true; pwrpriv->change_rfpwrstate = rf_on; pwrpriv->ips_leave_cnts++; DBG_871X("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts); if ((result = rtw_ips_pwr_up(padapter)) == _SUCCESS) { pwrpriv->rf_pwrstate = rf_on; } DBG_871X_LEVEL(_drv_always_, "nolinked power save leave\n"); DBG_871X("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c)); pwrpriv->bips_processing = false; pwrpriv->bkeepfwalive = false; pwrpriv->bpower_saving = false; } return result; }
void ips_enter(_adapter * padapter) { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); _enter_pwrlock(&pwrpriv->lock); _ips_enter(padapter); _exit_pwrlock(&pwrpriv->lock); }
void rtl8188e_set_FwPwrMode_cmd(PADAPTER padapter, u8 Mode) { SETPWRMODE_PARM H2CSetPwrMode; struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); u8 RLBM = 0; // 0:Min, 1:Max , 2:User define _func_enter_; DBG_871X("%s: Mode=%d SmartPS=%d UAPSD=%d\n", __FUNCTION__, Mode, pwrpriv->smart_ps, padapter->registrypriv.uapsd_enable); H2CSetPwrMode.AwakeInterval = 2; //DTIM = 1 switch(Mode) { case PS_MODE_ACTIVE: H2CSetPwrMode.Mode = 0; break; case PS_MODE_MIN: H2CSetPwrMode.Mode = 1; break; case PS_MODE_MAX: RLBM = 1; H2CSetPwrMode.Mode = 1; break; case PS_MODE_DTIM: RLBM = 2; H2CSetPwrMode.AwakeInterval = 3; //DTIM = 2 H2CSetPwrMode.Mode = 1; break; case PS_MODE_UAPSD_WMM: H2CSetPwrMode.Mode = 2; break; default: H2CSetPwrMode.Mode = 0; break; } //H2CSetPwrMode.Mode = Mode; H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps<<4)&0xf0) | (RLBM & 0x0f)); H2CSetPwrMode.bAllQueueUAPSD = padapter->registrypriv.uapsd_enable; if(Mode > 0) { H2CSetPwrMode.PwrState = 0x00;// AllON(0x0C), RFON(0x04), RFOFF(0x00) #ifdef CONFIG_EXT_CLK H2CSetPwrMode.Mode |= BIT(7);//supporting 26M XTAL CLK_Request feature. #endif //CONFIG_EXT_CLK } else H2CSetPwrMode.PwrState = 0x0C;// AllON(0x0C), RFON(0x04), RFOFF(0x00) FillH2CCmd_88E(padapter, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode); _func_exit_; }
/* * ATTENTION: * Before calling this function pwrctrl lock should be occupied already, * otherwise it may return incorrect value. */ u32 rtw_ps_deny_get(PADAPTER padapter) { u32 deny; deny = adapter_to_pwrctl(padapter)->ps_deny; return deny; }
/* * ATTENTION: *Before calling this function pwrctrl lock should be occupied already, *otherwise it may return incorrect value. */ u32 rtw_ps_deny_get(struct adapter *padapter) { u32 deny; deny = adapter_to_pwrctl(padapter)->ps_deny; return deny; }
void rtl8723b_HalDmWatchDog( IN PADAPTER Adapter ) { bool bFwCurrentInPSMode = false; bool bFwPSAwake = true; u8 hw_init_completed = false; PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); hw_init_completed = Adapter->hw_init_completed; if (hw_init_completed == false) goto skip_dm; bFwCurrentInPSMode = adapter_to_pwrctl(Adapter)->bFwCurrentInPSMode; rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bFwPSAwake)); if ((hw_init_completed == true) && ((!bFwCurrentInPSMode) && bFwPSAwake)) { /* */ /* Calculate Tx/Rx statistics. */ /* */ dm_CheckStatistics(Adapter); rtw_hal_check_rxfifo_full(Adapter); } /* ODM */ if (hw_init_completed == true) { u8 bLinked =false; u8 bsta_state =false; u8 bBtDisabled = true; if (rtw_linked_check(Adapter)){ bLinked = true; if (check_fwstate(&Adapter->mlmepriv, WIFI_STATION_STATE)) bsta_state = true; } ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_LINK, bLinked); ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_STATION_STATE, bsta_state); /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */ bBtDisabled = rtw_btcoex_IsBtDisabled(Adapter); ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_BT_ENABLED, ((bBtDisabled == true)?false:true)); ODM_DMWatchdog(&pHalData->odmpriv); } skip_dm: return; }
static void Update_ODM_ComInfo_8723b(PADAPTER Adapter) { struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; struct dvobj_priv *dvobj = adapter_to_dvobj(Adapter); struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(Adapter); PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); struct dm_priv *pdmpriv = &pHalData->dmpriv; int i; pdmpriv->InitODMFlag = 0 | ODM_BB_DIG | ODM_BB_RA_MASK | ODM_BB_DYNAMIC_TXPWR | ODM_BB_FA_CNT | ODM_BB_RSSI_MONITOR | ODM_BB_CCK_PD | ODM_BB_PWR_SAVE | ODM_BB_CFO_TRACKING | ODM_MAC_EDCA_TURBO | ODM_RF_TX_PWR_TRACK | ODM_RF_CALIBRATION #ifdef CONFIG_ODM_ADAPTIVITY | ODM_BB_ADAPTIVITY #endif ; /* */ /* Pointer reference */ /* */ /* ODM_CMNINFO_MAC_PHY_MODE pHalData->MacPhyMode92D */ /* ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_MAC_PHY_MODE,&(pDM_Odm->u1Byte_temp)); */ ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_TX_UNI,&(dvobj->traffic_stat.tx_bytes)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_RX_UNI,&(dvobj->traffic_stat.rx_bytes)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_WM_MODE,&(pmlmeext->cur_wireless_mode)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_CHNL_OFFSET,&(pHalData->nCur40MhzPrimeSC)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_MODE,&(Adapter->securitypriv.dot11PrivacyAlgrthm)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_BW,&(pHalData->CurrentChannelBW)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_CHNL,&(pHalData->CurrentChannel)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_NET_CLOSED,&(Adapter->net_closed)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_MP_MODE,&(Adapter->registrypriv.mp_mode)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_BAND,&(pHalData->CurrentBandType)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_FORCED_IGI_LB,&(pHalData->u1ForcedIgiLb)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_FORCED_RATE,&(pHalData->ForcedDataRate)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SCAN,&(pmlmepriv->bScanInProcess)); ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_POWER_SAVING,&(pwrctrlpriv->bpower_saving)); for (i = 0; i < NUM_STA; i++) ODM_CmnInfoPtrArrayHook(pDM_Odm, ODM_CMNINFO_STA_STATUS, i, NULL); }
static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr) { struct adapter *adapter; u8 mac_pwr_ctrl_on; u8 device_id; u16 offset; u32 ftaddr; u8 shift; u32 val; s32 err; __le32 le_tmp; adapter = intfhdl->padapter; ftaddr = _cvrt2ftaddr(addr, &device_id, &offset); rtw_hal_get_hwreg(adapter, HW_VAR_APFM_ON_MAC, &mac_pwr_ctrl_on); if ( ((device_id == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || (!mac_pwr_ctrl_on) || (adapter_to_pwrctl(adapter)->bFwCurrentInPSMode) ) { err = sd_cmd52_read(intfhdl, ftaddr, 4, (u8 *)&le_tmp); #ifdef SDIO_DEBUG_IO if (!err) { #endif return le32_to_cpu(le_tmp); #ifdef SDIO_DEBUG_IO } DBG_8192C(KERN_ERR "%s: Mac Power off, Read FAIL(%d)! addr = 0x%x\n", __func__, err, addr); return SDIO_ERR_VAL32; #endif } /* 4 bytes alignment */ shift = ftaddr & 0x3; if (shift == 0) { val = sd_read32(intfhdl, ftaddr, NULL); } else { u8 *tmpbuf; tmpbuf = rtw_malloc(8); if (!tmpbuf) { DBG_8192C(KERN_ERR "%s: Allocate memory FAIL!(size =8) addr = 0x%x\n", __func__, addr); return SDIO_ERR_VAL32; } ftaddr &= ~(u16)0x3; sd_read(intfhdl, ftaddr, 8, tmpbuf); memcpy(&le_tmp, tmpbuf+shift, 4); val = le32_to_cpu(le_tmp); kfree(tmpbuf); } return val; }
/* * ATTENTION: * rtw_ps_processor() doesn't handle LPS. */ void rtw_ps_processor(_adapter*padapter) { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); struct dvobj_priv *psdpriv = padapter->dvobj; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; u32 ps_deny = 0; down(&adapter_to_pwrctl(padapter)->lock); ps_deny = rtw_ps_deny_get(padapter); up(&adapter_to_pwrctl(padapter)->lock); if (ps_deny != 0) { DBG_871X(FUNC_ADPT_FMT ": ps_deny =0x%08X, skip power save!\n", FUNC_ADPT_ARG(padapter), ps_deny); goto exit; } if (pwrpriv->bInSuspend == true){/* system suspend or autosuspend */ pdbgpriv->dbg_ps_insuspend_cnt++; DBG_871X("%s, pwrpriv->bInSuspend == true ignore this process\n", __FUNCTION__); return; } pwrpriv->ps_processing = true; if (pwrpriv->ips_mode_req == IPS_NONE) goto exit; if (rtw_pwr_unassociated_idle(padapter) == false) goto exit; if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) ==0)) { DBG_871X("==>%s\n", __FUNCTION__); pwrpriv->change_rfpwrstate = rf_off; { ips_enter(padapter); } } exit: pwrpriv->ps_processing = false; return; }
s32 sdio_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8* pbuf) { PADAPTER padapter; u8 bMacPwrCtrlOn; u8 deviceId; u16 offset; u32 ftaddr; u8 shift; s32 err; _func_enter_; padapter = pintfhdl->padapter; err = 0; ftaddr = _cvrt2ftaddr(addr, &deviceId, &offset); rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); if (((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || (_FALSE == bMacPwrCtrlOn) #ifdef CONFIG_LPS_LCLK || (_TRUE == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) #endif ) { err = sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf); return err; } shift = ftaddr & 0x3; if (shift == 0) { err = sd_write(pintfhdl, ftaddr, cnt, pbuf); } else { u8 *ptmpbuf; u32 n; ftaddr &= ~(u16)0x3; n = cnt + shift; ptmpbuf = rtw_malloc(n); if (NULL == ptmpbuf) return -1; err = sd_read(pintfhdl, ftaddr, 4, ptmpbuf); if (err) { rtw_mfree(ptmpbuf, n); return err; } _rtw_memcpy(ptmpbuf+shift, pbuf, cnt); err = sd_write(pintfhdl, ftaddr, n, ptmpbuf); rtw_mfree(ptmpbuf, n); } _func_exit_; return err; }
int ips_leave(_adapter * padapter) { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); int ret; _enter_pwrlock(&pwrpriv->lock); ret = _ips_leave(padapter); _exit_pwrlock(&pwrpriv->lock); return ret; }
void rtw_hal_dm_watchdog_in_lps(_adapter *padapter) { #if defined(CONFIG_CONCURRENT_MODE) if (padapter->iface_type != IFACE_PORT0) return; #endif if (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode ==_TRUE ) { padapter->HalFunc.hal_dm_watchdog_in_lps(padapter);//this fuction caller is in interrupt context } }
void ips_enter(_adapter * padapter) { struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); down(&pwrpriv->lock); _ips_enter(padapter); up(&pwrpriv->lock); }
void rtw_btcoex_LPS_Enter(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv; u8 lpsVal; pwrpriv = adapter_to_pwrctl(padapter); pwrpriv->bpower_saving = true; lpsVal = rtw_btcoex_LpsVal(padapter); rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, lpsVal, "BTCOEX"); }
void rtw_btcoex_LPS_Leave(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv; pwrpriv = adapter_to_pwrctl(padapter); if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "BTCOEX"); LPS_RF_ON_check(padapter, 100); pwrpriv->bpower_saving = false; } }