// the input parameter start use the same unit as returned by rtw_get_current_time inline s32 rtw_get_passing_time_ms(u32 start) { #ifdef PLATFORM_LINUX return rtw_systime_to_ms(jiffies-start); #endif #ifdef PLATFORM_FREEBSD return rtw_systime_to_ms(rtw_get_current_time()); #endif #ifdef PLATFORM_WINDOWS LARGE_INTEGER SystemTime; NdisGetCurrentSystemTime(&SystemTime); return rtw_systime_to_ms((u32)(SystemTime.LowPart) - start) ; #endif }
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 = adapter_to_pwrctl(padapter); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; _irqL irqL; u32 start = rtw_get_current_time(); struct dvobj_priv *psdpriv = padapter->dvobj; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; DBG_871X("%s\n", __FUNCTION__); psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; #ifdef CONFIG_LPS rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "SRESET"); #endif//#ifdef CONFIG_LPS _enter_pwrlock(&pwrpriv->lock); 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_pwrlock(&pwrpriv->lock); DBG_871X("%s done in %d ms\n", __FUNCTION__, rtw_get_passing_time_ms(start)); pdbgpriv->dbg_sreset_cnt++; #endif }
void rtw_ips_pwr_down(_adapter *padapter) { u32 start_time = rtw_get_current_time(); DBG_8192C("===> rtw_ips_pwr_down...................\n"); padapter->bCardDisableWOHSM = _TRUE; padapter->net_closed = _TRUE; rtw_led_control(padapter, LED_CTL_POWER_OFF); rtw_ips_dev_unload(padapter); padapter->bCardDisableWOHSM = _FALSE; DBG_8192C("<=== rtw_ips_pwr_down..................... in %dms\n", rtw_get_passing_time_ms(start_time)); }
int rtw_ips_pwr_up(_adapter *padapter) { int result; u32 start_time = rtw_get_current_time(); DBG_8192C("===> rtw_ips_pwr_up..............\n"); rtw_reset_drv_sw(padapter); result = ips_netdrv_open(padapter); rtw_led_control(padapter, LED_CTL_NO_LINK); DBG_8192C("<=== rtw_ips_pwr_up.............. in %dms\n", rtw_get_passing_time_ms(start_time)); return result; }
void rtw_ips_pwr_down(struct adapter *padapter) { u32 start_time = rtw_get_current_time(); DBG_88E("===> rtw_ips_pwr_down...................\n"); padapter->bCardDisableWOHSM = true; padapter->net_closed = true; rtw_led_control(padapter, LED_CTL_POWER_OFF); rtw_ips_dev_unload(padapter); padapter->bCardDisableWOHSM = false; DBG_88E("<=== rtw_ips_pwr_down..................... in %dms\n", rtw_get_passing_time_ms(start_time)); }
void rtl8723a_sreset_xmit_status_check(_adapter *padapter) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; unsigned long current_time; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; unsigned int diff_time; u32 txdma_status; if( (txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS)) !=0x00){ DBG_8723A("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status); rtw_hal_sreset_reset(padapter); } #ifdef CONFIG_USB_HCI //total xmit irp = 4 //DBG_8723A("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt); //if(pxmitpriv->txirp_cnt == NR_XMITBUFF+1) current_time = rtw_get_current_time(); if(0 == pxmitpriv->free_xmitbuf_cnt || 0 == pxmitpriv->free_xmit_extbuf_cnt) { diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_time); if (diff_time > 2000) { if (psrtpriv->last_tx_complete_time == 0) { psrtpriv->last_tx_complete_time = current_time; } else{ diff_time = rtw_get_passing_time_ms(psrtpriv->last_tx_complete_time); if (diff_time > 4000) { //padapter->Wifi_Error_Status = WIFI_TX_HANG; DBG_8723A("%s tx hang\n", __FUNCTION__); rtw_hal_sreset_reset(padapter); } } } } #endif // #ifdef CONFIG_USB_HCI if (psrtpriv->dbg_trigger_point == SRESET_TGP_XMIT_STATUS) { psrtpriv->dbg_trigger_point = SRESET_TGP_NULL; rtw_hal_sreset_reset(padapter); return; } }
u8 PS_RDY_CHECK(_adapter * padapter) { u32 curr_time, delta_time; struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); #ifdef CONFIG_WOWLAN if(_TRUE == pwrpriv->bInSuspend && pwrpriv->wowlan_mode) return _TRUE; else if (_TRUE == pwrpriv->bInSuspend) return _FALSE; #else if(_TRUE == pwrpriv->bInSuspend ) return _FALSE; #endif curr_time = rtw_get_current_time(); delta_time = curr_time -pwrpriv->DelayLPSLastTimeStamp; if(delta_time < LPS_DELAY_TIME) { return _FALSE; } if ((check_fwstate(pmlmepriv, _FW_LINKED) == _FALSE) || (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == _TRUE) || (check_fwstate(pmlmepriv, WIFI_UNDER_WPS) == _TRUE) || (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE) ) return _FALSE; if( (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == _FALSE) ) { DBG_871X("Group handshake still in progress !!!\n"); return _FALSE; } #ifdef CONFIG_IOCTL_CFG80211 if (!rtw_cfg80211_pwr_mgmt(padapter)) return _FALSE; #endif return _TRUE; }
void rtw_hal_read_chip_info(_adapter *padapter) { u8 hci_type = rtw_get_intf_type(padapter); u32 start = rtw_get_current_time(); /* before access eFuse, make sure card enable has been called */ if ((hci_type == RTW_SDIO || hci_type == RTW_GSPI) && !rtw_is_hw_init_completed(padapter)) rtw_hal_power_on(padapter); padapter->HalFunc.read_adapter_info(padapter); if ((hci_type == RTW_SDIO || hci_type == RTW_GSPI) && !rtw_is_hw_init_completed(padapter)) rtw_hal_power_off(padapter); DBG_871X("%s in %d ms\n", __func__, rtw_get_passing_time_ms(start)); }
u8 _rtw_mi_busy_traffic_check(_adapter *padapter, void *data) { u32 passtime; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; bool check_sc_interval = *(bool *)data; if (pmlmepriv->LinkDetectInfo.bBusyTraffic == _TRUE) { if (check_sc_interval) { /* Miracast can't do AP scan*/ passtime = rtw_get_passing_time_ms(pmlmepriv->lastscantime); pmlmepriv->lastscantime = rtw_get_current_time(); if (passtime > BUSY_TRAFFIC_SCAN_DENY_PERIOD) { RTW_INFO(ADPT_FMT" bBusyTraffic == _TRUE\n", ADPT_ARG(padapter)); return _TRUE; } } else return _TRUE; } return _FALSE; }
void rtl8723b_sreset_xmit_status_check(_adapter *padapter) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; unsigned long current_time; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; unsigned int diff_time; u32 txdma_status; if( (txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS)) !=0x00){ DBG_871X("%s REG_TXDMA_STATUS:0x%08x\n", __FUNCTION__, txdma_status); rtl8723b_silentreset_for_specific_platform(padapter); } #ifdef CONFIG_USB_HCI //total xmit irp = 4 //DBG_8192C("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt); current_time = rtw_get_current_time(); if(0==pxmitpriv->free_xmitbuf_cnt) { diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time); if(diff_time > 2000){ if(psrtpriv->last_tx_complete_time==0){ psrtpriv->last_tx_complete_time = current_time; } else{ diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time); if(diff_time > 4000){ //padapter->Wifi_Error_Status = WIFI_TX_HANG; DBG_8192C("%s tx hang\n", __FUNCTION__); rtl8723b_silentreset_for_specific_platform(padapter); } } } } #endif // #ifdef CONFIG_USB_HCI }
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 }
void rtw_lps_leave(struct rtw_adapter *padapter) { #define LPS_LEAVE_TIMEOUT_MS 100 struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; u32 start_time; bool bAwake = false; #ifdef CONFIG_CONCURRENT_MODE if (padapter->iface_type != IFACE_PORT0) return; /* Skip power saving for concurrent mode port 1 */ #endif if (pwrpriv->bLeisurePs) { if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0); if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { start_time = rtw_get_current_time(); while (1) { rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bAwake)); if (bAwake || padapter->bSurpriseRemoved) break; if (rtw_get_passing_time_ms(start_time) > LPS_LEAVE_TIMEOUT_MS) { DBG_8192D ("Wait for FW LPS leave more than %u ms!!!\n", LPS_LEAVE_TIMEOUT_MS); break; } rtw_usleep_os(100); } } } } }
u8 rtw_handle_tkip_countermeasure(_adapter* padapter) { u8 status = _SUCCESS; u32 cur_time = 0; if (padapter->securitypriv.btkip_countermeasure == _TRUE) { cur_time = rtw_get_current_time(); if( (cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ ) { padapter->securitypriv.btkip_countermeasure = _FALSE; padapter->securitypriv.btkip_countermeasure_time = 0; } else { status = _FAIL; } } return status; }
void rtl8192c_sreset_xmit_status_check(_adapter *padapter) { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; unsigned long current_time; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; unsigned int diff_time; if(rtw_read32(padapter, REG_TXDMA_STATUS) !=0x00){ rtl8192c_silentreset_for_specific_platform(padapter); } //total xmit irp = 4 //DBG_8192C("==>%s free_xmitbuf_cnt(%d),txirp_cnt(%d)\n",__FUNCTION__,pxmitpriv->free_xmitbuf_cnt,pxmitpriv->txirp_cnt); //if(pxmitpriv->txirp_cnt == NR_XMITBUFF+1) current_time = rtw_get_current_time(); if(0==pxmitpriv->free_xmitbuf_cnt) { diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time); if(diff_time > 2000){ if(psrtpriv->last_tx_complete_time==0){ psrtpriv->last_tx_complete_time = current_time; } else{ diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time); if(diff_time > 4000){ //padapter->Wifi_Error_Status = WIFI_TX_HANG; DBG_8192C("tx hang...start reset\n"); rtl8192c_silentreset_for_specific_platform(padapter); } } } } }
int rtw_resume_process(_adapter *padapter) { struct net_device *pnetdev; struct pwrctrl_priv *pwrpriv; u8 is_pwrlock_hold_by_caller; u8 is_directly_called_by_auto_resume; int ret = 0; u32 start_time = rtw_get_current_time(); _func_enter_; DBG_871X("==> %s (%s:%d)\n",__FUNCTION__, current->comm, current->pid); rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_ON); rtw_mdelay_os(1); { u32 ret = 0; DBG_8192C("read start:\n"); //spi_write8_endian(padapter, SPI_LOCAL_OFFSET | 0xF0, 0x01, 1); rtw_write8(padapter, SPI_LOCAL_OFFSET | 0xF0, 0x03); ret = rtw_read32(padapter, SPI_LOCAL_OFFSET | 0xF0); DBG_8192C("read end 0xF0 read32:%x:\n", ret); DBG_8192C("read end 0xF0 read8:%x:\n", rtw_read8(padapter, SPI_LOCAL_OFFSET | 0xF0)); } if (padapter) { pnetdev = padapter->pnetdev; pwrpriv = &padapter->pwrctrlpriv; } else { ret = -1; goto exit; } // interface init if (gspi_init(adapter_to_dvobj(padapter)) != _SUCCESS) { ret = -1; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: initialize SDIO Failed!!\n", __FUNCTION__)); goto exit; } rtw_hal_disable_interrupt(padapter); if (gspi_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) { ret = -1; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: gspi_alloc_irq Failed!!\n", __FUNCTION__)); goto exit; } rtw_reset_drv_sw(padapter); pwrpriv->bkeepfwalive = _FALSE; DBG_871X("bkeepfwalive(%x)\n",pwrpriv->bkeepfwalive); if(pm_netdev_open(pnetdev,_TRUE) != 0) { ret = -1; goto exit; } netif_device_attach(pnetdev); netif_carrier_on(pnetdev); if( padapter->pid[1]!=0) { DBG_871X("pid[1]:%d\n",padapter->pid[1]); rtw_signal_process(padapter->pid[1], SIGUSR2); } #ifdef CONFIG_LAYER2_ROAMING_RESUME rtw_roaming(padapter, NULL); #endif #ifdef CONFIG_RESUME_IN_WORKQUEUE rtw_unlock_suspend(); #endif //CONFIG_RESUME_IN_WORKQUEUE exit: pwrpriv->bInSuspend = _FALSE; DBG_871X("<=== %s return %d.............. in %dms\n", __FUNCTION__ , ret, rtw_get_passing_time_ms(start_time)); _func_exit_; return ret; }
static int rtw_gspi_suspend(struct spi_device *spi, pm_message_t mesg) { struct dvobj_priv *dvobj = spi_get_drvdata(spi); PADAPTER padapter = dvobj->if1; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct net_device *pnetdev = padapter->pnetdev; int ret = 0; u32 start_time = rtw_get_current_time(); _func_enter_; DBG_871X("==> %s (%s:%d)\n",__FUNCTION__, current->comm, current->pid); pwrpriv->bInSuspend = _TRUE; while (pwrpriv->bips_processing == _TRUE) rtw_msleep_os(1); if((!padapter->bup) || (padapter->bDriverStopped)||(padapter->bSurpriseRemoved)) { DBG_871X("%s bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", __FUNCTION__ ,padapter->bup, padapter->bDriverStopped,padapter->bSurpriseRemoved); goto exit; } rtw_cancel_all_timer(padapter); LeaveAllPowerSaveMode(padapter); //padapter->net_closed = _TRUE; //s1. if(pnetdev) { netif_carrier_off(pnetdev); rtw_netif_stop_queue(pnetdev); } #ifdef CONFIG_WOWLAN padapter->pwrctrlpriv.bSupportRemoteWakeup=_TRUE; #else //s2. //s2-1. issue rtw_disassoc_cmd to fw disconnect_hdl(padapter, NULL); //rtw_disassoc_cmd(padapter); #endif #ifdef CONFIG_LAYER2_ROAMING_RESUME if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED) ) { DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n",__FUNCTION__, pmlmepriv->cur_network.network.Ssid.Ssid, MAC_ARG(pmlmepriv->cur_network.network.MacAddress), pmlmepriv->cur_network.network.Ssid.SsidLength, pmlmepriv->assoc_ssid.SsidLength); pmlmepriv->to_roaming = 1; } #endif //s2-2. indicate disconnect to os rtw_indicate_disconnect(padapter); //s2-3. rtw_free_assoc_resources(padapter, 1); //s2-4. rtw_free_network_queue(padapter, _TRUE); rtw_led_control(padapter, LED_CTL_POWER_OFF); rtw_dev_unload(padapter); if(check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) rtw_indicate_scan_done(padapter, 1); if(check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) rtw_indicate_disconnect(padapter); // interface deinit gspi_deinit(dvobj); RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("%s: deinit GSPI complete!\n", __FUNCTION__)); rtw_wifi_gpio_wlan_ctrl(WLAN_PWDN_OFF); rtw_mdelay_os(1); exit: DBG_871X("<=== %s return %d.............. in %dms\n", __FUNCTION__ , ret, rtw_get_passing_time_ms(start_time)); _func_exit_; return ret; }
u8 rtw_set_802_11_ssid(_adapter* padapter, NDIS_802_11_SSID *ssid) { _irqL irqL; u8 status = _SUCCESS; u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork = &pmlmepriv->cur_network; _func_enter_; DBG_871X_LEVEL(_drv_always_, "set ssid [%s] fw_state=0x%08x\n", ssid->Ssid, get_fwstate(pmlmepriv)); if(padapter->hw_init_completed==_FALSE){ RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("set_ssid: hw_init_completed==_FALSE=>exit!!!\n")); status = _FAIL; goto exit; } _enter_critical_bh(&pmlmepriv->lock, &irqL); DBG_871X("Set SSID under fw_state=0x%08x\n", get_fwstate(pmlmepriv)); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == _TRUE) { goto handle_tkip_countermeasure; } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == _TRUE) { goto release_mlme_lock; } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == _TRUE) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (_rtw_memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength) == _TRUE)) { if((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _FALSE)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set SSID is the same ssid, fw_state=0x%08x\n", get_fwstate(pmlmepriv))); if(rtw_is_same_ibss(padapter, pnetwork) == _FALSE) { //if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again rtw_disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } else { goto release_mlme_lock;//it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. } } #ifdef CONFIG_LPS else { rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); } #endif } else { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("Set SSID not the same ssid\n")); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_ssid=[%s] len=0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("assoc_ssid=[%s] len=0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); rtw_disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } } handle_tkip_countermeasure: #ifdef PLATFORM_WINDOWS if (padapter->securitypriv.btkip_countermeasure==_TRUE) { LARGE_INTEGER sys_time; u32 diff_time,cur_time ; RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("rtw_set_802_11_ssid:padapter->securitypriv.btkip_countermeasure==_TRUE\n")); NdisGetCurrentSystemTime(&sys_time); cur_time=(u32)(sys_time.QuadPart/10); // In micro-second. RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("rtw_set_802_11_ssid:cur_time=0x%x\n",cur_time)); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("rtw_set_802_11_ssid:psecuritypriv->last_mic_err_time=0x%x\n",padapter->securitypriv.btkip_countermeasure_time)); diff_time = cur_time -padapter->securitypriv.btkip_countermeasure_time; // In micro-second. RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("rtw_set_802_11_ssid:diff_time=0x%x\n",diff_time)); if (diff_time > 60000000) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("rtw_set_802_11_ssid(): countermeasure time >60s.\n")); padapter->securitypriv.btkip_countermeasure=_FALSE; // Update MIC error time. padapter->securitypriv.btkip_countermeasure_time=0; } else { // can't join in 60 seconds. status = _FAIL; RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("rtw_set_802_11_ssid(): countermeasure time <60s.\n")); goto release_mlme_lock; } } #endif #ifdef PLATFORM_LINUX if (padapter->securitypriv.btkip_countermeasure == _TRUE) { cur_time = rtw_get_current_time(); if( (cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ ) { padapter->securitypriv.btkip_countermeasure = _FALSE; padapter->securitypriv.btkip_countermeasure_time = 0; } else { status = _FAIL; goto release_mlme_lock; } } #endif #ifdef CONFIG_VALIDATE_SSID if (rtw_validate_ssid(ssid) == _FALSE) { status = _FAIL; goto release_mlme_lock; } #endif _rtw_memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(NDIS_802_11_SSID)); pmlmepriv->assoc_by_bssid=_FALSE; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == _TRUE) { pmlmepriv->to_join = _TRUE; } else { status = rtw_do_join(padapter); } release_mlme_lock: _exit_critical_bh(&pmlmepriv->lock, &irqL); exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("-rtw_set_802_11_ssid: status=%d\n", status)); _func_exit_; return status; }
u8 rtw_set_802_11_bssid(_adapter* padapter, u8 *bssid) { _irqL irqL; u8 status=_SUCCESS; u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; _func_enter_; DBG_871X_LEVEL(_drv_always_, "set bssid:%pM\n", bssid); if ((bssid[0]==0x00 && bssid[1]==0x00 && bssid[2]==0x00 && bssid[3]==0x00 && bssid[4]==0x00 &&bssid[5]==0x00) || (bssid[0]==0xFF && bssid[1]==0xFF && bssid[2]==0xFF && bssid[3]==0xFF && bssid[4]==0xFF &&bssid[5]==0xFF)) { status = _FAIL; goto exit; } _enter_critical_bh(&pmlmepriv->lock, &irqL); DBG_871X("Set BSSID under fw_state=0x%08x\n", get_fwstate(pmlmepriv)); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == _TRUE) { goto handle_tkip_countermeasure; } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == _TRUE) { goto release_mlme_lock; } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == _TRUE) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if (_rtw_memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN) == _TRUE) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _FALSE) goto release_mlme_lock;//it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. } else { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("Set BSSID not the same bssid\n")); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("set_bssid="MAC_FMT"\n", MAC_ARG(bssid) )); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("cur_bssid="MAC_FMT"\n", MAC_ARG(pmlmepriv->cur_network.network.MacAddress) )); rtw_disassoc_cmd(padapter); if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } } handle_tkip_countermeasure: //should we add something here...? #ifdef PLATFORM_LINUX if (padapter->securitypriv.btkip_countermeasure == _TRUE) { cur_time = rtw_get_current_time(); if( (cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ ) { padapter->securitypriv.btkip_countermeasure = _FALSE; padapter->securitypriv.btkip_countermeasure_time = 0; } else { status = _FAIL; goto release_mlme_lock; } } #endif _rtw_memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); pmlmepriv->assoc_by_bssid=_TRUE; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == _TRUE) { pmlmepriv->to_join = _TRUE; } else { status = rtw_do_join(padapter); } release_mlme_lock: _exit_critical_bh(&pmlmepriv->lock, &irqL); exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid: status=%d\n", status)); _func_exit_; return status; }
u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) { _irqL irqL; unsigned int pipe; int status; u32 ret = _FAIL, bwritezero = _FALSE; PURB purb = NULL; _adapter *padapter = (_adapter *)pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_buf *pxmitbuf = (struct xmit_buf *)wmem; struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; struct pkt_attrib *pattrib = &pxmitframe->attrib; _func_enter_; RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("+usb_write_port\n")); if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) ||(padapter->pwrctrlpriv.pnp_bstop_trx)) { #ifdef DBG_TX DBG_871X(" DBG_TX %s:%d bDriverStopped%d, bSurpriseRemoved:%d, pnp_bstop_trx:%d\n",__FUNCTION__, __LINE__ ,padapter->bDriverStopped, padapter->bSurpriseRemoved, padapter->pwrctrlpriv.pnp_bstop_trx ); #endif RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); goto exit; } _enter_critical(&pxmitpriv->lock, &irqL); switch(addr) { case VO_QUEUE_INX: pxmitpriv->voq_cnt++; pxmitbuf->flags = VO_QUEUE_INX; break; case VI_QUEUE_INX: pxmitpriv->viq_cnt++; pxmitbuf->flags = VI_QUEUE_INX; break; case BE_QUEUE_INX: pxmitpriv->beq_cnt++; pxmitbuf->flags = BE_QUEUE_INX; break; case BK_QUEUE_INX: pxmitpriv->bkq_cnt++; pxmitbuf->flags = BK_QUEUE_INX; break; case HIGH_QUEUE_INX: pxmitbuf->flags = HIGH_QUEUE_INX; break; default: pxmitbuf->flags = MGT_QUEUE_INX; break; } _exit_critical(&pxmitpriv->lock, &irqL); purb = pxmitbuf->pxmit_urb[0]; #if 0 if(pdvobj->ishighspeed) { if(cnt> 0 && cnt%512 == 0) { //DBG_8192C("ishighspeed, cnt=%d\n", cnt); bwritezero = _TRUE; } } else { if(cnt > 0 && cnt%64 == 0) { //DBG_8192C("cnt=%d\n", cnt); bwritezero = _TRUE; } } #endif //translate DMA FIFO addr to pipehandle pipe = ffaddr2pipehdl(pdvobj, addr); #ifdef CONFIG_REDUCE_USB_TX_INT if ( (pxmitpriv->free_xmitbuf_cnt%NR_XMITBUFF == 0) || (pxmitbuf->ext_tag == _TRUE) ) { purb->transfer_flags &= (~URB_NO_INTERRUPT); } else { purb->transfer_flags |= URB_NO_INTERRUPT; //DBG_8192C("URB_NO_INTERRUPT "); } #endif usb_fill_bulk_urb(purb, pusbd, pipe, pxmitframe->buf_addr, //= pxmitbuf->pbuf cnt, usb_write_port_complete, pxmitbuf);//context is pxmitbuf #ifdef CONFIG_USE_USB_BUFFER_ALLOC_TX purb->transfer_dma = pxmitbuf->dma_transfer_addr; purb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; purb->transfer_flags |= URB_ZERO_PACKET; #endif // CONFIG_USE_USB_BUFFER_ALLOC_TX #if 0 if (bwritezero) { purb->transfer_flags |= URB_ZERO_PACKET; } #endif status = usb_submit_urb(purb, GFP_ATOMIC); if (!status) { #ifdef DBG_CONFIG_ERROR_DETECT { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); pHalData->srestpriv.last_tx_time = rtw_get_current_time(); } #endif } else { rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); DBG_871X("usb_write_port, status=%d\n", status); RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port(): usb_submit_urb, status=%x\n", status)); switch (status) { case -ENODEV: padapter->bDriverStopped=_TRUE; break; default: break; } goto exit; } ret= _SUCCESS; // Commented by Albert 2009/10/13 // We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. /* if(bwritezero == _TRUE) { usb_bulkout_zero(pintfhdl, addr); } */ RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("-usb_write_port\n")); exit: if (ret != _SUCCESS) rtw_free_xmitbuf(pxmitpriv, pxmitbuf); _func_exit_; return ret; }
static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) { _irqL irqL; int i; struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; //struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; //_adapter *padapter = pxmitframe->padapter; _adapter *padapter = pxmitbuf->padapter; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; //struct pkt_attrib *pattrib = &pxmitframe->attrib; _func_enter_; switch(pxmitbuf->flags) { case VO_QUEUE_INX: pxmitpriv->voq_cnt--; break; case VI_QUEUE_INX: pxmitpriv->viq_cnt--; break; case BE_QUEUE_INX: pxmitpriv->beq_cnt--; break; case BK_QUEUE_INX: pxmitpriv->bkq_cnt--; break; case HIGH_QUEUE_INX: #ifdef CONFIG_AP_MODE rtw_chk_hi_queue_cmd(padapter); #endif break; default: break; } /* _enter_critical(&pxmitpriv->lock, &irqL); pxmitpriv->txirp_cnt--; switch(pattrib->priority) { case 1: case 2: pxmitpriv->bkq_cnt--; //DBG_8192C("pxmitpriv->bkq_cnt=%d\n", pxmitpriv->bkq_cnt); break; case 4: case 5: pxmitpriv->viq_cnt--; //DBG_8192C("pxmitpriv->viq_cnt=%d\n", pxmitpriv->viq_cnt); break; case 6: case 7: pxmitpriv->voq_cnt--; //DBG_8192C("pxmitpriv->voq_cnt=%d\n", pxmitpriv->voq_cnt); break; case 0: case 3: default: pxmitpriv->beq_cnt--; //DBG_8192C("pxmitpriv->beq_cnt=%d\n", pxmitpriv->beq_cnt); break; } _exit_critical(&pxmitpriv->lock, &irqL); if(pxmitpriv->txirp_cnt==0) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete: txirp_cnt== 0, set allrxreturnevt!\n")); _rtw_up_sema(&(pxmitpriv->tx_retevt)); } */ //rtw_free_xmitframe(pxmitpriv, pxmitframe); if(padapter->bSurpriseRemoved || padapter->bDriverStopped ||padapter->bWritePortCancel) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); DBG_8192C("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x) \n", __FUNCTION__,padapter->bDriverStopped, padapter->bSurpriseRemoved,padapter->bReadPortCancel,pxmitbuf->ext_tag); goto check_completion; } if (purb->status==0) { } else { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete : purb->status(%d) != 0 \n", purb->status)); DBG_871X("###=> urb_write_port_complete status(%d)\n",purb->status); if((purb->status==-EPIPE)||(purb->status==-EPROTO)) { //usb_clear_halt(pusbdev, purb->pipe); //msleep(10); sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); } else if (purb->status == -EINPROGRESS) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete: EINPROGESS\n")); goto check_completion; } else if (purb->status == -ENOENT) { DBG_871X("%s: -ENOENT\n", __func__); goto check_completion; } else if (purb->status == -ECONNRESET) { DBG_871X("%s: -ECONNRESET\n", __func__); goto check_completion; } else if (purb->status == -ESHUTDOWN) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete: ESHUTDOWN\n")); padapter->bDriverStopped=_TRUE; RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete:bDriverStopped=TRUE\n")); goto check_completion; } else { padapter->bSurpriseRemoved=_TRUE; DBG_8192C("bSurpriseRemoved=TRUE\n"); //rtl8192cu_trigger_gpio_0(padapter); RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete:bSurpriseRemoved=TRUE\n")); goto check_completion; } } #ifdef DBG_CONFIG_ERROR_DETECT { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); pHalData->srestpriv.last_tx_complete_time = rtw_get_current_time(); } #endif check_completion: _enter_critical(&pxmitpriv->lock_sctx, &irqL); rtw_sctx_done_err(&pxmitbuf->sctx, purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS); _exit_critical(&pxmitpriv->lock_sctx, &irqL); rtw_free_xmitbuf(pxmitpriv, pxmitbuf); //if(rtw_txframes_pending(padapter)) { tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } _func_exit_; }
u8 rtw_set_802_11_ssid(struct rtw_adapter *padapter, struct ndis_802_11_ssid *ssid) { u8 status = _SUCCESS; u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork = &pmlmepriv->cur_network; _func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+rtw_set_802_11_ssid: ssid =[%s] fw_state= 0x%08x\n", ssid->Ssid, get_fwstate(pmlmepriv))); if (padapter->hw_init_completed == false) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("set_ssid: hw_init_completed== false=>exit!!!\n")); status = _FAIL; goto exit; } spin_lock_bh(&pmlmepriv->lock); DBG_8192D("Set SSID under fw_state= 0x%08x\n", get_fwstate(pmlmepriv)); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) goto handle_tkip_countermeasure; else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) goto release_mlme_lock; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (_rtw_memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength) == true)) { if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set SSID is the same ssid, fw_state= 0x%08x\n", get_fwstate(pmlmepriv))); if (rtw_is_same_ibss(padapter, pnetwork) == false) { /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ rtw_disassoc_cmd(padapter, 0, true); if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } else { goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } } #ifdef CONFIG_LPS else { rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); } #endif } else { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n")); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len= 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len= 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); rtw_disassoc_cmd(padapter, 0, true); if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } } handle_tkip_countermeasure: if (padapter->securitypriv.btkip_countermeasure == true) { cur_time = rtw_get_current_time(); if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { padapter->securitypriv.btkip_countermeasure = false; padapter->securitypriv.btkip_countermeasure_time = 0; } else { status = _FAIL; goto release_mlme_lock; } } #ifdef CONFIG_VALIDATE_SSID if (rtw_validate_ssid(ssid) == false) { status = _FAIL; goto release_mlme_lock; } #endif memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); pmlmepriv->assoc_by_bssid = false; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) pmlmepriv->to_join = true; else status = rtw_do_join(padapter); release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("-rtw_set_802_11_ssid: status=%d\n", status)); _func_exit_; return status; }
void rtw_set_ps_mode(PADAPTER padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; #ifdef CONFIG_P2P struct wifidirect_info *pwdinfo = &( padapter->wdinfo ); #endif //CONFIG_P2P #ifdef CONFIG_TDLS struct sta_priv *pstapriv = &padapter->stapriv; _irqL irqL; int i, j; _list *plist, *phead; struct sta_info *ptdls_sta; #endif //CONFIG_TDLS _func_enter_; RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: PowerMode=%d Smart_PS=%d\n", __FUNCTION__, ps_mode, smart_ps)); if(ps_mode > PM_Card_Disable) { RT_TRACE(_module_rtl871x_pwrctrl_c_,_drv_err_,("ps_mode:%d error\n", ps_mode)); return; } if (pwrpriv->pwr_mode == ps_mode) { if (PS_MODE_ACTIVE == ps_mode) return; if ((pwrpriv->smart_ps == smart_ps) && (pwrpriv->bcn_ant_mode == bcn_ant_mode)) { return; } } #ifdef CONFIG_LPS_LCLK _enter_pwrlock(&pwrpriv->lock); #endif //if(pwrpriv->pwr_mode == PS_MODE_ACTIVE) if(ps_mode == PS_MODE_ACTIVE) { #ifdef CONFIG_P2P_PS if(pwdinfo->opp_ps == 0) #endif //CONFIG_P2P_PS { DBG_871X("rtw_set_ps_mode: Leave 802.11 power save\n"); #ifdef CONFIG_TDLS _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); for(i=0; i< NUM_STA; i++) { phead = &(pstapriv->sta_hash[i]); plist = get_next(phead); while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) { ptdls_sta = LIST_CONTAINOR(plist, struct sta_info, hash_list); if( ptdls_sta->tdls_sta_state & TDLS_LINKED_STATE ) issue_nulldata_to_TDLS_peer_STA(padapter, ptdls_sta, 0); plist = get_next(plist); } } _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); #endif //CONFIG_TDLS pwrpriv->pwr_mode = ps_mode; rtw_set_rpwm(padapter, PS_STATE_S4); #ifdef CONFIG_WOWLAN if (padapter->pwrctrlpriv.wowlan_mode == _TRUE) { u32 start_time, delay_ms; u8 val8; delay_ms = 20; start_time = rtw_get_current_time(); do { val8 = rtw_read8(padapter, 0x90); if (!(val8 & BIT(0))) break; if (rtw_get_passing_time_ms(start_time) > delay_ms) { DBG_871X("%s: Wait for FW 32K leave more than %u ms!!!\n", __FUNCTION__, delay_ms); break; } rtw_usleep_os(100); } while (1); pwrpriv->cpwm = PS_STATE_S4; } #endif rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); pwrpriv->bFwCurrentInPSMode = _FALSE; } }
static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) { _irqL irqL; int i; struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; _adapter *padapter = pxmitbuf->padapter; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; _func_enter_; switch (pxmitbuf->flags) { case VO_QUEUE_INX: pxmitpriv->voq_cnt--; break; case VI_QUEUE_INX: pxmitpriv->viq_cnt--; break; case BE_QUEUE_INX: pxmitpriv->beq_cnt--; break; case BK_QUEUE_INX: pxmitpriv->bkq_cnt--; break; case HIGH_QUEUE_INX: #ifdef CONFIG_AP_MODE rtw_chk_hi_queue_cmd(padapter); #endif break; default: break; } if (padapter->bSurpriseRemoved || padapter->bDriverStopped ||padapter->bWritePortCancel) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); DBG_88E("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n", __func__,padapter->bDriverStopped, padapter->bSurpriseRemoved,padapter->bReadPortCancel,pxmitbuf->ext_tag); goto check_completion; } if (purb->status==0) { } else { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete : purb->status(%d) != 0\n", purb->status)); DBG_88E("###=> urb_write_port_complete status(%d)\n",purb->status); if ((purb->status==-EPIPE)||(purb->status==-EPROTO)) { sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); } else if (purb->status == -EINPROGRESS) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete: EINPROGESS\n")); goto check_completion; } else if (purb->status == -ENOENT) { DBG_88E("%s: -ENOENT\n", __func__); goto check_completion; } else if (purb->status == -ECONNRESET) { DBG_88E("%s: -ECONNRESET\n", __func__); goto check_completion; } else if (purb->status == -ESHUTDOWN) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete: ESHUTDOWN\n")); padapter->bDriverStopped=true; RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete:bDriverStopped=true\n")); goto check_completion; } else { padapter->bSurpriseRemoved=true; DBG_88E("bSurpriseRemoved=true\n"); //rtl8192cu_trigger_gpio_0(padapter); RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_write_port_complete:bSurpriseRemoved=true\n")); goto check_completion; } } { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); pHalData->srestpriv.last_tx_complete_time = rtw_get_current_time(); } check_completion: rtw_sctx_done_err(&pxmitbuf->sctx, purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS); rtw_free_xmitbuf(pxmitpriv, pxmitbuf); //if (rtw_txframes_pending(padapter)) { tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } _func_exit_; }
void rtw_mstat_update(const enum mstat_f flags, const MSTAT_STATUS status, u32 sz) { static u32 update_time = 0; int peak, alloc; int i; /* initialization */ if(!update_time) { for(i=0;i<mstat_tf_idx(MSTAT_TYPE_MAX);i++) { ATOMIC_SET(&(rtw_mem_type_stat[i].alloc), 0); ATOMIC_SET(&(rtw_mem_type_stat[i].peak), 0); ATOMIC_SET(&(rtw_mem_type_stat[i].alloc_cnt), 0); ATOMIC_SET(&(rtw_mem_type_stat[i].alloc_err_cnt), 0); } #ifdef RTW_MEM_FUNC_STAT for(i=0;i<mstat_ff_idx(MSTAT_FUNC_MAX);i++) { ATOMIC_SET(&(rtw_mem_func_stat[i].alloc), 0); ATOMIC_SET(&(rtw_mem_func_stat[i].peak), 0); ATOMIC_SET(&(rtw_mem_func_stat[i].alloc_cnt), 0); ATOMIC_SET(&(rtw_mem_func_stat[i].alloc_err_cnt), 0); } #endif } switch(status) { case MSTAT_ALLOC_SUCCESS: ATOMIC_INC(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_cnt)); alloc = ATOMIC_ADD_RETURN(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc), sz); peak=ATOMIC_READ(&(rtw_mem_type_stat[mstat_tf_idx(flags)].peak)); if (peak<alloc) ATOMIC_SET(&(rtw_mem_type_stat[mstat_tf_idx(flags)].peak), alloc); #ifdef RTW_MEM_FUNC_STAT ATOMIC_INC(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_cnt)); alloc = ATOMIC_ADD_RETURN(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc), sz); peak=ATOMIC_READ(&(rtw_mem_func_stat[mstat_ff_idx(flags)].peak)); if (peak<alloc) ATOMIC_SET(&(rtw_mem_func_stat[mstat_ff_idx(flags)].peak), alloc); #endif break; case MSTAT_ALLOC_FAIL: ATOMIC_INC(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_err_cnt)); #ifdef RTW_MEM_FUNC_STAT ATOMIC_INC(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_err_cnt)); #endif break; case MSTAT_FREE: ATOMIC_DEC(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_cnt)); ATOMIC_SUB(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc), sz); #ifdef RTW_MEM_FUNC_STAT ATOMIC_DEC(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_cnt)); ATOMIC_SUB(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc), sz); #endif break; }; //if (rtw_get_passing_time_ms(update_time) > 5000) { // rtw_mstat_dump(RTW_DBGDUMP); update_time=rtw_get_current_time(); //} }
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; #ifdef CONFIG_P2P struct wifidirect_info *pwdinfo = &(adapter->wdinfo); #ifdef CONFIG_IOCTL_CFG80211 struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &adapter->cfg80211_wdinfo; #endif #endif bool ret = _FALSE; if (adapter->pwrctrlpriv.ips_deny_time >= rtw_get_current_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) #if defined(CONFIG_P2P) && defined(CONFIG_IOCTL_CFG80211) && defined(CONFIG_P2P_IPS) || pcfg80211_wdinfo->is_ro_ch #elif defined(CONFIG_P2P) || !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) #endif ) { goto exit; } /* consider buddy, if exist */ if (buddy) { struct mlme_priv *b_pmlmepriv = &(buddy->mlmepriv); #ifdef CONFIG_P2P struct wifidirect_info *b_pwdinfo = &(buddy->wdinfo); #ifdef CONFIG_IOCTL_CFG80211 struct cfg80211_wifidirect_info *b_pcfg80211_wdinfo = &buddy->cfg80211_wdinfo; #endif #endif 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) #if defined(CONFIG_P2P) && defined(CONFIG_IOCTL_CFG80211) && defined(CONFIG_P2P_IPS) || b_pcfg80211_wdinfo->is_ro_ch #elif defined(CONFIG_P2P) || !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE) #endif ) { goto exit; } } #if (MP_DRIVER == 1) if (adapter->registrypriv.mp_mode == 1) goto exit; #endif #ifdef CONFIG_INTEL_PROXIM if(adapter->proximity.proxim_on==_TRUE){ return; } #endif 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_info_, "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; }
bool rtw_pwr_unassociated_idle(_adapter *adapter) { _adapter *buddy = adapter->pbuddy_adapter; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); #ifdef CONFIG_P2P struct wifidirect_info *pwdinfo = &(adapter->wdinfo); #ifdef CONFIG_IOCTL_CFG80211 struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &adapter->cfg80211_wdinfo; #endif #endif bool ret = _FALSE; if (adapter->pwrctrlpriv.ips_deny_time >= rtw_get_current_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) #if defined(CONFIG_P2P) && defined(CONFIG_IOCTL_CFG80211) && defined(CONFIG_P2P_IPS) || pcfg80211_wdinfo->is_ro_ch #elif defined(CONFIG_P2P) || !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) #endif ) { goto exit; } /* consider buddy, if exist */ if (buddy) { struct mlme_priv *b_pmlmepriv = &(buddy->mlmepriv); #ifdef CONFIG_P2P struct wifidirect_info *b_pwdinfo = &(buddy->wdinfo); #ifdef CONFIG_IOCTL_CFG80211 struct cfg80211_wifidirect_info *b_pcfg80211_wdinfo = &buddy->cfg80211_wdinfo; #endif #endif 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) #if defined(CONFIG_P2P) && defined(CONFIG_IOCTL_CFG80211) && defined(CONFIG_P2P_IPS) || b_pcfg80211_wdinfo->is_ro_ch #elif defined(CONFIG_P2P) || !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE) #endif ) { goto exit; } } #ifdef CONFIG_INTEL_PROXIM if(adapter->proximity.proxim_on==_TRUE){ return; } #endif ret = _TRUE; exit: return ret; }
u8 rtw_set_802_11_bssid(struct rtw_adapter *padapter, u8 *bssid) { u8 status = _SUCCESS; u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; _func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+rtw_set_802_11_bssid: bssid =%pM\n", bssid)); if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) || (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) { status = _FAIL; goto exit; } spin_lock_bh(&pmlmepriv->lock); DBG_8192D("Set BSSID under fw_state= 0x%08x\n", get_fwstate(pmlmepriv)); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) goto handle_tkip_countermeasure; else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) goto release_mlme_lock; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if (_rtw_memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN) == true) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n")); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid =%pM\n", bssid)); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid =%pM\n", pmlmepriv->cur_network.network.MacAddress)); rtw_disassoc_cmd(padapter, 0, true); if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } } } handle_tkip_countermeasure: /* should we add something here...? */ if (padapter->securitypriv.btkip_countermeasure == true) { cur_time = rtw_get_current_time(); if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { padapter->securitypriv.btkip_countermeasure = false; padapter->securitypriv.btkip_countermeasure_time = 0; } else { status = _FAIL; goto release_mlme_lock; } } memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); pmlmepriv->assoc_by_bssid = true; if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) pmlmepriv->to_join = true; else status = rtw_do_join(padapter); release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid: status=%d\n", status)); _func_exit_; return status; }
static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) { _irqL irqL; int i; struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; /* struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; */ /* _adapter *padapter = pxmitframe->padapter; */ _adapter *padapter = pxmitbuf->padapter; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; /* struct pkt_attrib *pattrib = &pxmitframe->attrib; */ switch (pxmitbuf->flags) { case VO_QUEUE_INX: pxmitpriv->voq_cnt--; break; case VI_QUEUE_INX: pxmitpriv->viq_cnt--; break; case BE_QUEUE_INX: pxmitpriv->beq_cnt--; break; case BK_QUEUE_INX: pxmitpriv->bkq_cnt--; break; default: break; } /* _enter_critical(&pxmitpriv->lock, &irqL); pxmitpriv->txirp_cnt--; switch(pattrib->priority) { case 1: case 2: pxmitpriv->bkq_cnt--; break; case 4: case 5: pxmitpriv->viq_cnt--; break; case 6: case 7: pxmitpriv->voq_cnt--; break; case 0: case 3: default: pxmitpriv->beq_cnt--; break; } _exit_critical(&pxmitpriv->lock, &irqL); if(pxmitpriv->txirp_cnt==0) { _rtw_up_sema(&(pxmitpriv->tx_retevt)); } */ /* rtw_free_xmitframe(pxmitpriv, pxmitframe); */ if (RTW_CANNOT_TX(padapter)) { RTW_INFO("%s(): TX Warning! bDriverStopped(%s) OR bSurpriseRemoved(%s) pxmitbuf->buf_tag(%x)\n" , __func__ , rtw_is_drv_stopped(padapter) ? "True" : "False" , rtw_is_surprise_removed(padapter) ? "True" : "False" , pxmitbuf->buf_tag); goto check_completion; } if (purb->status == 0) { } else { RTW_INFO("###=> urb_write_port_complete status(%d)\n", purb->status); if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) { /* usb_clear_halt(pusbdev, purb->pipe); */ /* msleep(10); */ sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); } else if (purb->status == -EINPROGRESS) { goto check_completion; } else if (purb->status == -ENOENT) { RTW_INFO("%s: -ENOENT\n", __func__); goto check_completion; } else if (purb->status == -ECONNRESET) { RTW_INFO("%s: -ECONNRESET\n", __func__); goto check_completion; } else if (purb->status == -ESHUTDOWN) { rtw_set_drv_stopped(padapter); goto check_completion; } else { rtw_set_surprise_removed(padapter); RTW_INFO("bSurpriseRemoved=TRUE\n"); goto check_completion; } } #ifdef DBG_CONFIG_ERROR_DETECT { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); pHalData->srestpriv.last_tx_complete_time = rtw_get_current_time(); } #endif check_completion: _enter_critical(&pxmitpriv->lock_sctx, &irqL); rtw_sctx_done_err(&pxmitbuf->sctx, purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS); _exit_critical(&pxmitpriv->lock_sctx, &irqL); rtw_free_xmitbuf(pxmitpriv, pxmitbuf); /* if(rtw_txframes_pending(padapter)) */ { tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } }
void rtw_handle_tkip_mic_err(_adapter *padapter,u8 bgroup) { #ifdef CONFIG_IOCTL_CFG80211 enum nl80211_key_type key_type = 0; #endif union iwreq_data wrqu; struct iw_michaelmicfailure ev; struct mlme_priv* pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 cur_time = 0; if( psecuritypriv->last_mic_err_time == 0 ) { psecuritypriv->last_mic_err_time = rtw_get_current_time(); } else { cur_time = rtw_get_current_time(); if( cur_time - psecuritypriv->last_mic_err_time < 60*HZ ) { psecuritypriv->btkip_countermeasure = _TRUE; psecuritypriv->last_mic_err_time = 0; psecuritypriv->btkip_countermeasure_time = cur_time; } else { psecuritypriv->last_mic_err_time = rtw_get_current_time(); } } #ifdef CONFIG_IOCTL_CFG80211 if ( bgroup ) { key_type |= NL80211_KEYTYPE_GROUP; } else { key_type |= NL80211_KEYTYPE_PAIRWISE; } cfg80211_michael_mic_failure(padapter->pnetdev, (u8 *)&pmlmepriv->assoc_bssid[ 0 ], key_type, -1, NULL, GFP_ATOMIC); #endif _rtw_memset( &ev, 0x00, sizeof( ev ) ); if ( bgroup ) { ev.flags |= IW_MICFAILURE_GROUP; } else { ev.flags |= IW_MICFAILURE_PAIRWISE; } ev.src_addr.sa_family = ARPHRD_ETHER; _rtw_memcpy( ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN ); _rtw_memset( &wrqu, 0x00, sizeof( wrqu ) ); wrqu.data.length = sizeof( ev ); #ifndef CONFIG_IOCTL_CFG80211 wireless_send_event( padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu, (char*) &ev ); #endif }
u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) { _irqL irqL; unsigned int pipe; int status; u32 ret = _FAIL, bwritezero = _FALSE; PURB purb = NULL; _adapter *padapter = (_adapter *)pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); struct pwrctrl_priv *pwrctl = dvobj_to_pwrctl(pdvobj); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_buf *pxmitbuf = (struct xmit_buf *)wmem; struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; struct pkt_attrib *pattrib = &pxmitframe->attrib; if (RTW_CANNOT_TX(padapter)) { #ifdef DBG_TX RTW_INFO(" DBG_TX %s:%d bDriverStopped%s, bSurpriseRemoved:%s\n", __func__, __LINE__ , rtw_is_drv_stopped(padapter) ? "True" : "False" , rtw_is_surprise_removed(padapter) ? "True" : "False"); #endif rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); goto exit; } _enter_critical(&pxmitpriv->lock, &irqL); switch (addr) { case VO_QUEUE_INX: pxmitpriv->voq_cnt++; pxmitbuf->flags = VO_QUEUE_INX; break; case VI_QUEUE_INX: pxmitpriv->viq_cnt++; pxmitbuf->flags = VI_QUEUE_INX; break; case BE_QUEUE_INX: pxmitpriv->beq_cnt++; pxmitbuf->flags = BE_QUEUE_INX; break; case BK_QUEUE_INX: pxmitpriv->bkq_cnt++; pxmitbuf->flags = BK_QUEUE_INX; break; case HIGH_QUEUE_INX: pxmitbuf->flags = HIGH_QUEUE_INX; break; default: pxmitbuf->flags = MGT_QUEUE_INX; break; } _exit_critical(&pxmitpriv->lock, &irqL); purb = pxmitbuf->pxmit_urb[0]; /* translate DMA FIFO addr to pipehandle */ #ifdef RTW_HALMAC pipe = ffaddr2pipehdl(pdvobj, pxmitbuf->bulkout_id); #else pipe = ffaddr2pipehdl(pdvobj, addr); #endif #ifdef CONFIG_REDUCE_USB_TX_INT if ((pxmitpriv->free_xmitbuf_cnt % NR_XMITBUFF == 0) || (pxmitbuf->buf_tag > XMITBUF_DATA)) purb->transfer_flags &= (~URB_NO_INTERRUPT); else { purb->transfer_flags |= URB_NO_INTERRUPT; /* RTW_INFO("URB_NO_INTERRUPT "); */ } #endif usb_fill_bulk_urb(purb, pusbd, pipe, pxmitframe->buf_addr, /* = pxmitbuf->pbuf */ cnt, usb_write_port_complete, pxmitbuf);/* context is pxmitbuf */ #ifdef CONFIG_USE_USB_BUFFER_ALLOC_TX purb->transfer_dma = pxmitbuf->dma_transfer_addr; purb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; purb->transfer_flags |= URB_ZERO_PACKET; #endif /* CONFIG_USE_USB_BUFFER_ALLOC_TX */ #ifdef USB_PACKET_OFFSET_SZ #if (USB_PACKET_OFFSET_SZ == 0) purb->transfer_flags |= URB_ZERO_PACKET; #endif #endif #if 0 if (bwritezero) purb->transfer_flags |= URB_ZERO_PACKET; #endif status = usb_submit_urb(purb, GFP_ATOMIC); if (!status) { #ifdef DBG_CONFIG_ERROR_DETECT { HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); pHalData->srestpriv.last_tx_time = rtw_get_current_time(); } #endif } else { rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); RTW_INFO("usb_write_port, status=%d\n", status); switch (status) { case -ENODEV: rtw_set_drv_stopped(padapter); break; default: break; } goto exit; } ret = _SUCCESS; /* Commented by Albert 2009/10/13 * We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */ /* if(bwritezero == _TRUE) { usb_bulkout_zero(pintfhdl, addr); } */ exit: if (ret != _SUCCESS) rtw_free_xmitbuf(pxmitpriv, pxmitbuf); return ret; }