实现 USB 空闲请求 IRP 完成例程

调用 MiniportIdleNotification 时,USB 微型端口驱动程序调用 IoCallDriver , (IRP) 发出 USB 空闲请求的 I/O 请求数据包, (IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION) 到基础 USB 总线驱动程序。 微型端口驱动程序会发出此 IRP,以通知 USB 总线驱动程序网络适配器处于空闲状态,必须挂起。

USB 微型端口驱动程序还必须调用 IoSetCompletionRoutineEx ,以便为 USB 空闲请求 IRP 注册完成例程。 USB 总线驱动程序在完成 IRP 后被 USB 微型端口驱动程序取消后调用完成例程。 当 NDIS 通过调用 MiniportCancelIdleNotification 取消空闲通知时,USB 微型端口驱动程序将取消 IRP。

完成例程只需调用 NdisMIdleNotificationComplete 即可通知 NDIS 它可以继续网络适配器的全电源状态转换。

注意 如果 USB 微型端口驱动程序将在来自 NDIS 的另一个空闲通知期间重复使用 IRP 资源,则完成例程必须返回STATUS_MORE_PROCESSING_REQUIRED。

下面是 USB 空闲请求 IRP 的完成例程的示例。

//
// MiniportUsbIdleRequestCompletion()
//
// This is the IO_COMPLETION_ROUTINE for the selective suspend IOCTL.
// All that is needed is to inform NDIS that the IdleNotification
// operation is complete.
//
VOID MiniportUsbIdleRequestCompletion(PVOID AdapterContext)
{
    NdisMIdleNotificationComplete(Adapter->MiniportAdapterHandle);

    // We will be reusing the IRP later, so do not let the IO manager delete it.
    return STATUS_MORE_PROCESSING_REQUIRED;
}

有关 USB 空闲请求回调例程的详细信息,请参阅 USB 空闲请求 IRP 完成例程。