Technical Document #17

Technical Document #17
How can I improve my driver's performance with WinDriver?

The performance of the driver you develop and the data transfer rate is dependent on the specific OS, the hardware and the driver design.

For suggestions on how to improve the performance of your WinDriver-based driver, please refer to the Performance Page on our web site and to the "Performance Improvement" Chapter in the WinDriver User's Manual.

Following are some suggestions for improving your driver's performance with WinDriver:

For PCI/CardBus/PCMCIA/ISA

NOTE

The following explanations refer to the low-level WD_xxx WinDriver API. For updated guidelines on how to improve your driver's performance using the high-level WDC_xxx WinDriver PCI API, refer to the Improving Performance chapter in the WinDriver PCI User's Manual.

You can access memory addresses directly from your user mode application, instead of calling WD_Transfer() to access the memory in the kernel.
For direct memory access, use the user-mode mapping returned from WD_CardRegister() in:
cardReg.Card.Item[i].I.Mem.dwUserDirectAddr
— see the description of WD_CardRegister() in the manual.

When accessing I/O addresses you might improve the driver's performance by using string transfers and/or replacing multiple calls to WD_Transfer() with a single call to WD_MultiTransfer().
This is also true for memory access, but direct memory access is faster.

To further improve the driver's performance, you can use WinDriver's Kernel PlugIn feature in order to move performance critical sections of your code from the user mode to the kernel, thereby improving the overall performance of your driver. This feature will allow you, for example, to handle interrupts directly in the kernel (see also: Technical Document #48 with regard to the Kernel PlugIn interrupt latency). A detailed description of the Kernel PlugIn feature can be found in the WinDriver User's Manual.
The Kernel PlugIn is not supported on Windows CE and VxWorks, since these operating systems do not distinguish between user and kernel mode. On VxWorks (last supported in WinDriver v5.2.2) you can improve the interrupt handling rate by using the windrvr_isr callback function, as explained in the manual and in Technical Document #115.

For USB

To increase the data transfer rate you can try replacing several data transfers, which use relatively small data buffers, with a single transfer that uses a big data buffer, thereby eliminating some of the function call overhead and reducing the context switches between the user and kernel mode.
(The size of the data buffer is set in the dwBufferSize parameter of the WDU_Transfer() function.)
NOTE: The size of the buffer used in the calls to WDU_Transfer() is not limited to the maximum packet size for the device, although we recommend that you use buffer sizes that are multiples of the maximum packet size.

You might also be able to improve the transfer rate by modifying the device's firmware (for example, by increasing the maximum packet size for the hardware).