Implementing a MiniportCancelIdleNotification Handler Function

NDIS calls the miniport driver's MiniportCancelIdleNotification handler function in order to cancel the idle notification process and transition the network adapter to a full-power state. When this function is called, the miniport driver must follow these steps:

  1. The miniport driver must cancel any bus-specific IRPs that it may have previously issued for the idle notification.

  2. The miniport driver calls NdisMIdleNotificationComplete. This call notifies NDIS that the idle notification has been completed. NDIS then compiles the selective suspend operation by transitioning the network adapter to a full-power state.

For example, when MiniportCancelIdleNotification is called, the USB miniport driver calls IoCancelIrp to cancel the I/O request packet (IRP) for a USB idle request (IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION). The USB miniport driver previously issued this IRP in its MiniportIdleNotification handler function. As soon as the USB bus driver has canceled the IRP, it calls the IRP's completion routine. When the USB bus driver calls the completion routine, it confirms that the IRP is canceled and the device can resume to a full-power state. In the context of the completion routine, the miniport driver calls NdisMIdleNotificationComplete.

Note  The USB bus driver can call the completion routine either synchronously in the context of the call to IoCancelIrp or asynchronously after MiniportCancelIdleNotification returns.

The following is an example of a MiniportCancelIdleNotification handler function for a USB miniport driver. This example shows the steps that are involved with canceling a USB idle request IRP.

//
// MiniportCancelIdleNotification()
//
// This routine is called if NDIS has to cancel an idle notification.
// All that is needed is to cancel the selective suspend IRP.
//
VOID MiniportCancelIdleNotification(
    _In_ NDIS_HANDLE MiniportAdapterContext
    )
{
    IoCancelIrp(Adapter->UsbSsIrp);
}

For guidelines on implementing a completion routine for a USB idle request IRP, see Implementing a USB Idle Request IRP Completion Routine.