override AdapterObject->GetScatterGatherList in WDF?

I expect that I’ll need to abandon the WDF for the DMA support in my driver, but I thought I’d ask this question just in case…

I need to control the maximum size of the chains in a scatter-gather dma transaction. In the KMDF, when I call WdfDmaTransactionExecute, I suspect that the framework calls the embedded AdapterObjects GetScattterGatherList DmaOperation to build the scatter gather list. This DmaOperation, however, doesn’t take a parameter to define how big the chains can get; so, I expect that it would normally try to build a list with the fewest number of elements each of which is as large a chunk of contiguous memory possible for the buffer being mapped.

I, however, want to override this behavior such that building the list would involve a loop calling the AdapterObject MapTransfer DmaOperation specifying the max dma chain size for each iteration.

I’d like to continue using the WDF to manage the resources with a limited substitution for the scatter-gather list. Is this possible? How? Or am I stuck managing the whole thing myself starting with creating the AdapterObject via IoGetDmaAdapter?

Thanks,
Larry

Can you describe what you mean by a “chain”? Are you talking about a chained MDL?

Is the issue that your device has a limit on how big any given element in a scatter gather list can be?

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@measurementcomputing.com
Sent: Friday, February 05, 2010 9:24 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] override AdapterObject->GetScatterGatherList in WDF?

I expect that I’ll need to abandon the WDF for the DMA support in my driver, but I thought I’d ask this question just in case…

I need to control the maximum size of the chains in a scatter-gather dma transaction. In the KMDF, when I call WdfDmaTransactionExecute, I suspect that the framework calls the embedded AdapterObjects GetScattterGatherList DmaOperation to build the scatter gather list. This DmaOperation, however, doesn’t take a parameter to define how big the chains can get; so, I expect that it would normally try to build a list with the fewest number of elements each of which is as large a chunk of contiguous memory possible for the buffer being mapped.

I, however, want to override this behavior such that building the list would involve a loop calling the AdapterObject MapTransfer DmaOperation specifying the max dma chain size for each iteration.

I’d like to continue using the WDF to manage the resources with a limited substitution for the scatter-gather list. Is this possible? How? Or am I stuck managing the whole thing myself starting with creating the AdapterObject via IoGetDmaAdapter?

Thanks,
Larry


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

WDF (XP and above) uses BuildScatterGahterList DMA API. The buffer that WDF uses for the SG list is the max possible based on the NumberOfMapRegisters returned when it called IoGetDmaAdapter.
I.e., it calls CalculateScatterGatherList(…, NumberofMapRegisters*PAGE_SIZE, &ListSize, …) (mdl arg is null here).

Egi.

Hi Peter,

By “chain”, I mean each transfer operation is an a dma transaction. This would correspond to a single element in the scatter gather list.

Yes, that issue does involve limitation of the device and its use. I actually modify the size of each transfer according to what the user is trying to do. The device performs paced analog-to-digital conversions (and vice versa) at rates for 1 Hz to 1 MHz. Often, the customer wants to see the data as it’s acquired–think of an oscilloscope or strip chart, for instance. So, I have to make a trade-off between efficiency(or performance) and responsiveness(how often they see updates); the faster the conversions, the bigger each transfer. But for low rates, I have to reduce the size of the transfers so that the customer isn’t waiting too long between updates.

Unfortunately, I don’t think I can get away with packet based DMA since the device is always gathering data whether the driver has programmed the next transfer or not.

Thanks for taking an interest.
Larry

Ah - I see your other post and I think I understand better.

The scatter gather list the DMA DDI gives you back does not have to be the same one you give your hardware. You’re free to subdivide individual elements as much as you need. So if you get one 0x1000 byte element and you need 0x400 byte chunks, do the math yourself to convert that into 0x400 byte chunks.

This will still be more efficient than trying to do it yourself using AllocateAdapterChannel and MapTransfer.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Friday, February 05, 2010 9:56 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] override AdapterObject->GetScatterGatherList in WDF?

Can you describe what you mean by a “chain”? Are you talking about a chained MDL?

Is the issue that your device has a limit on how big any given element in a scatter gather list can be?

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@measurementcomputing.com
Sent: Friday, February 05, 2010 9:24 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] override AdapterObject->GetScatterGatherList in WDF?

I expect that I’ll need to abandon the WDF for the DMA support in my driver, but I thought I’d ask this question just in case…

I need to control the maximum size of the chains in a scatter-gather dma transaction. In the KMDF, when I call WdfDmaTransactionExecute, I suspect that the framework calls the embedded AdapterObjects GetScattterGatherList DmaOperation to build the scatter gather list. This DmaOperation, however, doesn’t take a parameter to define how big the chains can get; so, I expect that it would normally try to build a list with the fewest number of elements each of which is as large a chunk of contiguous memory possible for the buffer being mapped.

I, however, want to override this behavior such that building the list would involve a loop calling the AdapterObject MapTransfer DmaOperation specifying the max dma chain size for each iteration.

I’d like to continue using the WDF to manage the resources with a limited substitution for the scatter-gather list. Is this possible? How? Or am I stuck managing the whole thing myself starting with creating the AdapterObject via IoGetDmaAdapter?

Thanks,
Larry


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

>Or am I stuck managing the whole thing myself starting with creating the AdapterObject via >IoGetDmaAdapter?
IoGetDmaAdapter and WdfDmaTransactionInitialize are very similar and contains a parameter “Length”, which define number to be transferred.

Igor Sharovar

Peter,

That’s fantastic! Easy and straightforward. You saved me a lot of rework.

Thanks,
Larry

Peter,

I wanted to thank you again. I have the DMA transfers working on both x86 and x64 platforms and am seeing the expected data coming across.

Thanks,
larry

Great. Glad to hear it worked out.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@measurementcomputing.com
Sent: Friday, February 05, 2010 12:34 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] override AdapterObject->GetScatterGatherList in WDF?

Peter,

I wanted to thank you again. I have the DMA transfers working on both x86 and x64 platforms and am seeing the expected data coming across.

Thanks,
larry


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer