2.6  Protocol Driver Reset Operations

A protocol driver can initiate a reset operation by calling NdisReset. If its reset request returns NDIS_STATUS_PENDING, ProtocolResetComplete is called when the reset operation is complete.

A protocol driver seldom calls NdisReset unless it has special knowledge that the underlying NIC is not functioning correctly. For instance, if a protocol driver detects that it has not received completion calls for an unusually large number of sends or requests, and it has enough knowledge of the underlying NIC to conclude that this indicates hardware problems, it can call NdisReset. Typically, however, the need for a reset is detected and initiated by NDIS and/or the NIC driver itself using time-out logic. Any protocol driver bound to an underlying NDIS driver that reports its medium type as NdisMediumWan cannot call NdisReset.

Typically, an underlying NIC driver resets its NIC because the NIC is timing out during send or request operations, which causes NDIS to call the NIC driver’s MiniportCheckForHang and subsequently MiniportReset function, or because the NIC driver determines the NIC's receive capability is disfunctional. If a reset is initiated by NDIS and MiniportReset returns NDIS_STATUS_PENDING, NDIS first calls the ProtocolStatus function of each bound protocol driver with a status of NDIS_STATUS_RESET_START, and then calls the same bound protocol driver’s ProtocolStatusComplete function. When the NIC driver calls NdisResetComplete, NDIS again calls ProtocolStatus with a status of NDIS_STATUS_RESET_END followed by a call to ProtocolStatusComplete.

A protocol driver must handle the possibility that outstanding sends on a binding to an underlying NIC can be cancelled because the NIC is reset. If a bound protocol driver has any transmit packets pending, NDIS will complete those packets back to the protocol driver with an appropriate status. The protocol driver must resubmit the packets again when the reset operation is completed, assuming the NIC becomes operational again.

When a protocol driver receives a status of NDIS_STATUS_RESET_START, it should do the following:

·Hold any packets ready to be transmitted until ProtocolStatus receives an NDIS_STATUS_RESET_END notification.

·Not make any NDIS calls directed to the underlying miniport, except calls to return resources such as returning packets with NdisReturnPackets.

After ProtocolStatus receives an NDIS_STATUS_RESET_END message and ProtocolStatusComplete is called, the protocol driver can resume sending packets and requests.