void pnp_resume_wk(void *context) { uint res = _SUCCESS; _adapter * padapter = (_adapter *)context; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct recv_priv *precvpriv = &padapter->recvpriv; padapter->pwrctrlpriv.pnp_bstop_trx=_FALSE; pxmitpriv->txirp_cnt = 1; precvpriv->rx_pending_cnt = 1; res = rtl871x_hal_init(padapter); if (res ==_FAIL) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,("\n========== pnp_hw_init_thread:init 8712 fail!!!!!!!!!!\n")); } if (padapter->dvobjpriv.inirp_init !=NULL) { padapter->dvobjpriv.inirp_init(padapter); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("\n pnp_hw_init_thread:rx irp init!!\n")); } padapter->hw_init_completed = _TRUE; NdisMSetInformationComplete(padapter->hndis_adapter, NDIS_STATUS_SUCCESS); }
void pnp_sleep_wk(void *context) { _irqL irqL; _adapter *padapter = (_adapter *)context; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv; RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("pnp_sleep_wk ===>\n")); _enter_critical(&pmlmepriv->lock, &irqL ); if(check_fwstate(pmlmepriv, _FW_LINKED)== _TRUE) { indicate_disconnect(padapter); //will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not free_assoc_resources(padapter); #ifndef CONFIG_POWER_DOWN_MODE disassoc_cmd(padapter); #endif } _exit_critical(&pmlmepriv->lock, &irqL ); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("pnp_sleep_wk:fwstate:%d\n", pmlmepriv->fw_state)); #ifdef CONFIG_POWER_DOWN_MODE //before enter powerdown mode, we must ensure FW in S4 state. if (padapter->pwrctrlpriv.pwr_mode > PS_MODE_ACTIVE) { padapter->pwrctrlpriv.pwr_mode = PS_MODE_ACTIVE; _enter_pwrlock(&(padapter->pwrctrlpriv.lock)); set_rpwm(padapter, PS_STATE_S4); _exit_pwrlock(&(padapter->pwrctrlpriv.lock)); } while (pwrctrl->cpwm != PS_STATE_S4) { //waiting FW to become ACTIVE. msleep_os(10); } #endif write16(padapter, SDIO_HIMR, 0); pwrctrl->pnp_bstop_trx = _TRUE; padapter->hw_init_completed = _FALSE; NdisMSetInformationComplete(padapter->hndis_adapter, NDIS_STATUS_SUCCESS); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("pnp_sleep_wk <===\n")); }
static void OnSetPowerWorkItem(NDIS_WORK_ITEM * pWorkItem, PVOID Context) { tPowerWorkItem *pwi = (tPowerWorkItem *)pWorkItem; PARANDIS_ADAPTER *pContext = pwi->pContext; if (pwi->state == NetDeviceStateD0) { ParaNdis_PowerOn(pContext); } else { ParaNdis_PowerOff(pContext); } NdisFreeMemory(pwi, 0, 0); ParaNdis_DebugHistory(pContext, hopOidRequest, NULL, OID_PNP_SET_POWER, 0, 2); NdisMSetInformationComplete(pContext->MiniportHandle, NDIS_STATUS_SUCCESS); }
VOID XenNet_SetPower(PDEVICE_OBJECT device_object, PVOID context) { NTSTATUS status = STATUS_SUCCESS; KIRQL old_irql; struct xennet_info *xi = context; FUNCTION_ENTER(); UNREFERENCED_PARAMETER(device_object); switch (xi->new_power_state) { case NdisDeviceStateD0: KdPrint((" NdisDeviceStateD0\n")); status = XenNet_D0Entry(xi); break; case NdisDeviceStateD1: KdPrint((" NdisDeviceStateD1\n")); if (xi->power_state == NdisDeviceStateD0) status = XenNet_D0Exit(xi); break; case NdisDeviceStateD2: KdPrint((" NdisDeviceStateD2\n")); if (xi->power_state == NdisDeviceStateD0) status = XenNet_D0Exit(xi); break; case NdisDeviceStateD3: KdPrint((" NdisDeviceStateD3\n")); if (xi->power_state == NdisDeviceStateD0) status = XenNet_D0Exit(xi); break; default: KdPrint((" NdisDeviceState??\n")); status = NDIS_STATUS_NOT_SUPPORTED; break; } xi->power_state = xi->new_power_state; old_irql = KeRaiseIrqlToDpcLevel(); NdisMSetInformationComplete(xi->adapter_handle, status); KeLowerIrql(old_irql); FUNCTION_EXIT(); }
void pnp_sleep_wk(void *context) { _irqL irqL; _adapter *padapter = (_adapter *)context; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv; _enter_critical(&pmlmepriv->lock, &irqL ); if (check_fwstate(pmlmepriv, _FW_LINKED)== _TRUE) { indicate_disconnect(padapter); //will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not } _exit_critical(&pmlmepriv->lock, &irqL ); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("\npnp_sleep_wk:fwstate:%d\n", pmlmepriv->fw_state)); pwrctrl->pnp_bstop_trx=_TRUE; //delay 1 second then cancel IRP //msleep_os(1000); //cancel irp // 1. tx/rx irp // 2.int irp // 3.reg read/write irp rtl871x_intf_stop(padapter); msleep_os(1000); //Turn off LDO rtl871x_hal_deinit(padapter); padapter->hw_init_completed = _FALSE; NdisMSetInformationComplete(padapter->hndis_adapter, NDIS_STATUS_SUCCESS); }
void pnp_resume_wk(void *context) { #ifdef CONFIG_POWER_DOWN_MODE NDIS_STATUS status; uint res = _SUCCESS; #endif u8 x = 0; _adapter * padapter = (_adapter *)context; RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("pnp_resume_wk ===>\n")); padapter->pwrctrlpriv.pnp_bstop_trx=_FALSE; #ifdef CONFIG_POWER_DOWN_MODE { BOOL fRet = FALSE; HANDLE hPMU = INVALID_HANDLE_VALUE; u32 stLdoData = 0; hPMU = CreateFile(_T("SDH1:"), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(INVALID_HANDLE_VALUE == hPMU ) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,("CreateFile Error SDH1==.\n")); } fRet=DeviceIoControl(hPMU, IOCTL_CARD_STATE_NOTIFY, NULL, 0, &stLdoData, sizeof(u32), NULL, NULL); if(!fRet) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,("DeviceIoControl Error \n")); } CloseHandle(hPMU); } //set 4-bit bus mode attrib_read(padapter, 0x7, 1, &x); x |= BIT(1); attrib_write(padapter, 0x7, 1, &x); //set Function 1 I/O Block Size to 512(0x0200) x = 0x00; attrib_write(padapter, 0x110, 1, &x); x = 0x02; attrib_write(padapter, 0x111, 1, &x); //set Function 1 I/O Enable attrib_read(padapter, 0x2, 1, &x); x |= BIT(1); attrib_write(padapter, 0x2, 1, &x); //set Function 1 Interrupt Enable x = BIT(0)|BIT(1); attrib_write(padapter, 0x4, 1, &x); status=padapter->dvobj_init(padapter); if (status != NDIS_STATUS_SUCCESS) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,("\n initialize device object priv Failed!\n")); } res = rtl871x_hal_init(padapter); if (res ==_FAIL) { RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,("\n========== pnp_hw_init_thread:init 8712 fail!!!!!!!!!!\n")); } #endif RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,("===>write SDIO_HIMR!!!\n")); write16(padapter, SDIO_HIMR, 0x3ff); { u32 tmp32; tmp32=read32(padapter, TXFF_EMPTY_TH); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,(" =====TXFF_EMPTY_TH=0x%.8x!\n",tmp32)); tmp32=tmp32 |0xfffff; write32(padapter, TXFF_EMPTY_TH, tmp32); tmp32=read32(padapter, TXFF_EMPTY_TH); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_err_,(" =====TXFF_EMPTY_TH=0x%.8x!\n",tmp32)); } padapter->hw_init_completed=_TRUE; #ifdef CONFIG_POWER_DOWN_MODE if(padapter->pwrctrlpriv.pwr_mode != padapter->registrypriv.power_mgnt){ set_ps_mode(padapter, padapter->registrypriv.power_mgnt, padapter->registrypriv.smart_ps); } #endif NdisMSetInformationComplete(padapter->hndis_adapter, NDIS_STATUS_SUCCESS); RT_TRACE(_module_rtl871x_ioctl_set_c_,_drv_info_,("pnp_resume_wk <===\n")); }
VOID natpRequestComplete( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_REQUEST NdisRequest, IN NDIS_STATUS Status ) { PINTERNAL_REQUEST pIntReq; PFILTER_ADAPTER pAdapt; NDIS_OID Oid; pAdapt = (PFILTER_ADAPTER)ProtocolBindingContext; Oid = pAdapt->IntReq.NdisRequest.DATA.SET_INFORMATION.Oid ; pIntReq = CONTAINING_RECORD( NdisRequest, INTERNAL_REQUEST, NdisRequest ); pIntReq->nRequestStatus = Status; if( NT_SUCCESS( Status ) ){ if( NdisRequest->DATA.QUERY_INFORMATION.BytesWritten > NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength) { NdisRequest->DATA.QUERY_INFORMATION.BytesWritten = NdisRequest->DATA.QUERY_INFORMATION.InformationBufferLength; } } if( pIntReq->bLocalRequest ){ if ( pIntReq->pLocalCompletionFunc ){ (*pIntReq->pLocalCompletionFunc)( pAdapt, pIntReq, Status ); } pAdapt->LocalOutstandingRequests = FALSE; return; } pAdapt->OutstandingRequests = FALSE; switch (NdisRequest->RequestType){ case NdisRequestQueryInformation: if ((Oid == OID_PNP_CAPABILITIES) && (Status == NDIS_STATUS_SUCCESS)) { natmQueryPNPCapabilities(pAdapt, &Status); } *pAdapt->BytesReadOrWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten; *pAdapt->BytesNeeded = NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded; if ((Oid == OID_GEN_MAC_OPTIONS) && (Status == NDIS_STATUS_SUCCESS)) *(PULONG)NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer &= ~NDIS_MAC_OPTION_NO_LOOPBACK; if ((Oid == OID_802_3_CURRENT_ADDRESS) && (Status == NDIS_STATUS_SUCCESS)) RtlCopyMemory(pAdapt->ctrl.MacAddr.Arr, NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer, 6); if(OID_TCP_TASK_OFFLOAD == Oid) Status = NDIS_STATUS_NOT_SUPPORTED; NdisMQueryInformationComplete(pAdapt->MiniportHandle, Status); break; case NdisRequestSetInformation: *pAdapt->BytesReadOrWritten = NdisRequest->DATA.SET_INFORMATION.BytesRead; *pAdapt->BytesNeeded = NdisRequest->DATA.SET_INFORMATION.BytesNeeded; if(OID_TCP_TASK_OFFLOAD == Oid) Status = NDIS_STATUS_NOT_SUPPORTED; NdisMSetInformationComplete(pAdapt->MiniportHandle,Status); break; default: break; } }
VOID PtRequestComplete( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_REQUEST NdisRequest, IN NDIS_STATUS Status ) /*++ Routine Description: Completion handler for the previously posted request. All OIDS are completed by and sent to the same miniport that they were requested for. If Oid == OID_PNP_QUERY_POWER then the data structure needs to returned with all entries = NdisDeviceStateUnspecified Arguments: ProtocolBindingContext Pointer to the adapter structure NdisRequest The posted request Status Completion status Return Value: None --*/ { PADAPT pAdapt =(PADAPT)ProtocolBindingContext; NDIS_OID Oid = pAdapt->Request.DATA.SET_INFORMATION.Oid ; // // Since our request is not outstanding anymore // pAdapt->OutstandingRequests = FALSE; // // Complete the Set or Query, and fill in the buffer for OID_PNP_CAPABILITIES, if need be. // switch (NdisRequest->RequestType) { case NdisRequestQueryInformation: // // We never pass OID_PNP_QUERY_POWER down. // ASSERT(Oid != OID_PNP_QUERY_POWER); if ((Oid == OID_PNP_CAPABILITIES) && (Status == NDIS_STATUS_SUCCESS)) { MPQueryPNPCapabilities(pAdapt, &Status); } *pAdapt->BytesReadOrWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten; *pAdapt->BytesNeeded = NdisRequest->DATA.QUERY_INFORMATION.BytesNeeded; if ((Oid == OID_GEN_MAC_OPTIONS) && (Status == NDIS_STATUS_SUCCESS)) { // // Remove the no-loopback bit from mac-options. In essence we are // telling NDIS that we can handle loopback. We don't, but the // interface below us does. If we do not do this, then loopback // processing happens both below us and above us. This is wasteful // at best and if Netmon is running, it will see multiple copies // of loopback packets when sniffing above us. // // Only the lowest miniport is a stack of layered miniports should // ever report this bit set to NDIS. // *(PULONG)NdisRequest->DATA.QUERY_INFORMATION.InformationBuffer &= ~NDIS_MAC_OPTION_NO_LOOPBACK; } NdisMQueryInformationComplete(pAdapt->MiniportHandle, Status); break; case NdisRequestSetInformation: ASSERT( Oid != OID_PNP_SET_POWER); *pAdapt->BytesReadOrWritten = NdisRequest->DATA.SET_INFORMATION.BytesRead; *pAdapt->BytesNeeded = NdisRequest->DATA.SET_INFORMATION.BytesNeeded; NdisMSetInformationComplete(pAdapt->MiniportHandle, Status); break; default: ASSERT(0); break; } }