I know this might sound like a strange question. I’ve waffled between being convinced one way and then the other and then to not sure and back.
Background: I’m working on an NDIS 6.0 driver for Windows Embedded Compact 7. There are minor differences, mostly relaxed requirements, but very similar to desktop Windows NDIS.
When performing the processing for preparing a NET_BUFFER (ethernet frame) for processing, I scan the MDL in the NET_BUFFER structure. I do some optimizations to determine if I need to allocate a Scatter-Gather List or if the packets are small enough, just copy them to a preallocated shared-memory buffer. Sometimes I have to create a Scatter-Gather list to process to send to my hardware. If the supplied buffer is not aligned on a 64-byte boundary (hardware requirement) I have to use both. I’m not really wanting to get into the details further than that.
Now for the question:
Is there a 1-to-1 relationship between the number of MDLs and the number of elements in the SGL? The documentation doesn’t address this specifically that I can tell.
My first assumption is the relationship is 1:1. I base this upon a comment in wdm.h that states “An MDL describes pages in a virtual buffer in terms of physical pages”. This would lead me to believe there is a 1:1 relationship because each SGL Element represents a group of contiguous pages and so does an MDL.
Any NDIS Internals experts have a better insight?
Thanks,
Greg