SCATTER_GATHER_LIST for an MDL - NdisBuildScatterGatherList

Hi

I am looking into feasiblity of a protocol driver and in it for the MDLs I have (in send or receive path) I need to get the Device-Bus-Logical-Address (LA) that NIC eventually uses for DMA, i.e outside of miniport context build the SGL by my own (The MDLs I got are already pinned/locked).

I was not sure if this is possible (because I am not a miniport and cannot call NdisMAllocateNetBufferSGList()), until I saw NdisBuildScatterGatherList().
I have below questions on NdisBuildScatterGatherList().

NdisMAllocateNetBufferSGList - https://msdn.microsoft.com/en-us/library/windows/hardware/ff562776(v=vs.85).aspx
NdisBuildScatterGatherList - https://msdn.microsoft.com/en-us/library/windows/hardware/ff561620(v=vs.85).aspx

  1. For PNDIS_SCATTER_GATHER_LIST_PARAMETERS param of NdisBuildScatterGatherList(), I will have to specify below default values for these members, is that O.k or any consequence? I am o.k. as long as no functional misses.

NDIS_RECEIVE_QUEUE_ID QueueId; –> 0
NDIS_SHARED_MEMORY_USAGE SharedMemoryUsage; –> undefined or other

  1. Also it states that NetProcessSGList() callback will be called **in the context** of NdisBuildScatterGatherList itself which is good.

“…NDIS calls the NetProcessSGList function that is specified at the ProcessSGListHandler member of the NDIS_SCATTER_GATHER_LIST_PARAMETERS structure **within the context** of NdisBuildScatterGatherList.”

NdisMAllocateNetBufferSGList() callback MiniportProcessSGList() callback has below semantics

“…HAL can call MiniportProcessSGList ***before or after*** NDIS returns from NdisMAllocateNetBufferSGList. Miniport drivers must not attempt to access the scatter/gather list until after HAL calls MiniportProcessSGList.”

Just curious why the callback semantics are different for each, though both look like functional equivalents or wrapper around same function.

  1. And one nitpick :-).
    One says IRQL DISPATCH_LEVEL and other says = DISPATCH_LEVEL. I know both are same/unambiguous, but I remembered this old thread http://osronline.com/showThread.CFM?link=174617 and want to be sure I was not dealing with a function which is always called at DISPATCH_LEVEL, but MSDN conservatively says <=DISPATCH_LEVEL. With former I can use SLockAtDPc() etc…

Thanks

xxxxx@yahoo.com wrote:

I am looking into feasiblity of a protocol driver and in it for the MDLs I have (in send or receive path) I need to get the Device-Bus-Logical-Address (LA) that NIC eventually uses for DMA, i.e outside of miniport context build the SGL by my own (The MDLs I got are already pinned/locked).

I’m not a network guy, so I don’t appreciate the fineries involved, but
this seems like a flawed design. A protocol driver is not supposed to
know anything about the hardware. How can you assume that the
underlying device is a PCI device, or that it eventually uses DMA at
all? What if there is bridging involved, so that you’re crossing
several physical adapters?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.