How to get Physical Address of Allocated MDL?

Hi All,

I am porting Windows 7 PCI WLAN driver to WEC7.

This is code in Windows 7:
PNET_BUFFER os_buf = NET_BUFFER_LIST_FIRST_NB((PNET_BUFFER_LIST)skb->wb_os_buf);
PMDL pmdl = NET_BUFFER_FIRST_MDL(os_buf);
ULONG length = 0;
int8_t *data = NULL;
PHYSICAL_ADDRESS addr;
NdisQueryMdl(pmdl, &data, &length, NormalPagePriority);
addr = MmGetPhysicalAddress(data);
skb->wb_mapped_paddr_lo[0] = addr.LowPart + NET_BUFFER_DATA_OFFSET(os_buf);

I got stuck with the API MmGetPhysicalAddress. I didn’t find equivalent API to this in WEC7. Can anyone help to proceed further.?

I got a clue from some forums and added the code as below. But i am not sure about its correctness. Replaced last two lines of Windows 7 code as …

DWORD pfn, offset_addr;
if(!LockPages(data, length, &pfn, (LOCKFLAG_READ | LOCKFLAG_WRITE)))
{
printk(“LockPages failed for block buffer\r\n”);
}
offset_addr = pfn << UserKInfo[KINX_PFN_SHIFT];
skb->wb_mapped_paddr_lo[0] = offset_addr + ((DWORD)NET_BUFFER_DATA_OFFSET(os_buf));

My requirement is to send some command to firmware, to do this I am allocating a buffer at lower layer. I am not using the buffers(tx/rx) allocated, using API NdisMAllocateSharedMemory, in InitializeHandlerEx to send commands to FW. As my network adapter is PCI, I need to map the virtual address to physical address of MDL to use DMA operations. How can I send/write commands to proper address to get interrupts from FW?

Thanks

You’re supposed to call NdisBuildScatterGatherList instead.

Hi Alex,

Could you elaborate more on usage of NdisBuildScatterGatherList.