2.4 Miniport NIC Driver Operations
To begin network communications, the miniport must register itself with the
NDIS library and initialize its device. The miniport NIC driver also allocates
memory for the packets and buffers it needs. After this initialization step,
protocol drivers can bind to the NIC managed by the miniport and submit
requests to the underlying NIC miniport. To submit requests, a protocol driver
calls the NDIS library supplying the handle to the NIC returned from its call
to NdisOpenAdapter. The NDIS library,
in turn, calls one of the upper-edge functions in the miniport.
A Typical Miniport Operation
Sending a packet across the network is a typical operation involving the
miniport. The following describes a common asynchronous operation:
-
To communicate with its remote-node peer, a highest-level protocol driver on a
local node repackages messages from upper level network layers into data
packets. The protocol driver then calls NDIS with the packet.
-
Assuming no intermediate NDIS driver between the highest level protocol driver
and the miniport NIC driver, NDIS calls the miniport’s MiniportSend function
with a pointer to the packet.
-
The NIC driver sets up its device, starts the send operation and returns
NDIS_STATUS_PENDING to NDIS.
-
When the NIC has finished transmitting the packet, it generates an interrupt,
which causes a call to the NDIS library.
-
The NDIS library calls the MiniportISR function for the NIC.
-
The miniport NIC driver performs only the minimum necessary work in
MiniportISR and returns, deferring most of the interrupt handling to
its MiniportHandleInterrupt function.
-
The NDIS library’s deferred processing function runs and then calls
MiniportHandleInterrupt to complete interrupt processing for the transmission.
MiniportHandleInterrupt completes the send and calls NdisMSendComplete.
NDIS calls the appropriate protocol driver’s ProtocolSendComplete function. A
NIC driver can wait to call NdisMSendComplete until it has completed
several transmits.
When return data is available from the remote node, the NIC captures the data
and interrupts. NDIS intercepts the interrupt and signals its miniport drive
either by calling MiniportISR or MiniportHandleInterrupt. The miniport copies
the data to a buffer and calls NdisM...IndicateReceive. NDIS notifies
the protocol driver of incoming packets by calling its ProtocolReceive
function and subsequently the miniport’s MiniportTransferData function is
called to transfer the data to a protocol driver-supplied packet.
NDIS Library Operations
The NdisXxx functions for miniports in the NDIS library assist
in handling multiprocessor synchronization operations, protocol filters, and
hardware problems on the NIC.
-
The NDIS library queues requests from different processors and sends them to
the miniport when the driver is free.
-
The NDIS library multiplexes requests from different protocols onto a single
miniport NIC driver for a specific network card.
-
The NDIS library has a built-in deadman timer that calls the
MiniportCheckForHang function periodically to detect problems on the network
interface card.
Miniport Driver Operations
The NDIS library maintains a driver-descriptor block for each miniport NIC
driver that registers itself on a network. The descriptor block contains the
addresses of the upper-edge functions exported by the miniport. With the
exception of MiniportISR, MiniportInitialize, possibly MiniportShutdown and
possibly MiniportHalt, miniport processing occurs at IRQL DISPATCH_LEVEL.
Typical operations are:
-
Initializing the NDIS library and registering the NIC driver.
-
Registering a network interface card.
-
Sending data.
-
Indicating and, possibly transferring received data.
-
Indicating status.
-
Querying and setting NIC and driver capabilities.
-
Querying global statistics (per network interface card).
-
Resetting a network interface card.
-
Removing a network interface card.
-
Unloading and deregistering drivers and terminating the NDIS library.
For help in following the descriptions, refer to the function definitions in Section
2.3. For more descriptions of the functions, refer to the Network Driver
Reference.