A.4.1.4  Using Shared Memory

Use of cached memory that is shared between a NIC driver and its netcard requires special precautions. Windows NT does not ensure execution of the NDIS interface library with an I/O-coherent cache, since a netcard can access physical memory directly while the NIC driver accesses memory through the cache. This can cause differences in what the driver and the netcard detect in memory, even if they look at the same location.

Use of noncached shared memory avoids most of the problems mentioned for cached shared memory. However, when data written to physical memory must use a small write queue, even noncached data might not appear in physical memory immediately. Additionally, there are cases when using noncached memory is not recommended or is not possible. For example, data the NIC driver reads repeatedly should always be cached to improve performance. The NIC driver should also use cached memory for any data that a transport driver passes in.

To help eliminate shared memory problems, use an NdisAllocateSharedMemory call in your NIC driver to allocate memory for permanent sharing between the netcard and the driver. This function writes a virtual address and a physical address for the shared memory. The physical address is valid until a call to NdisFreeSharedMemory frees the memory. To access the shared memory, your driver must call NdisUpdateSharedMemory.