Accomplish MSI-X for FILE_DEVICE_BUS_EXTENDER device in KMDF

Hi Experts,

I am new to windows driver. Am trying to develop a KMDF bus driver for a FILE_DEVICE_BUS_EXTENDER device.
I need to implement the MSI-X in my driver. I have gone through so many posts and links.
From that what I should follow to achieve the MSI-X in KMDF is :

  1. Enable the MSI-X in INF file.
  2. Create the interrupt object for each MSI vector.
    While creating the Interrupt Object,we also needs to consider the followings:
    i. Initialize the WDF_INTERRUPT_CONFIG_INIT with ISR(EvtInterruptIsr) and DPC(EvtInterruptDPC) if needed.
    ii. Register EvtInterruptEnable and EvtInterruptDisable to enable/disable the interrupts by accessing the hardware registries.
    iii. Create the Interrupt Object.
  3. Handle the Interrupt resources under CmResourceTypeInterrupt.(As framework handles this by default,we no need to do anything).

This is the basic idea which i have known so far. And also still I need clear understanding about this EvtInterruptIsr and EvtInterruptDpc callback functions.
As these callbacks are used to handle the device interrupts,what I should do here. Please if anyone knews about these callback function,make a brief note of it.

Also please make sure that the steps I gave above is enough to achieve MSI-X for my FILE_DEVICE_BUS_EXTENDER device. Is there anything that seems to
be missing in the steps I mentioned above,also please make a note of it.

Thanks in ADVANCE…

xxxxx@gmail.com wrote:

I am new to windows driver. Am trying to develop a KMDF bus driver for a FILE_DEVICE_BUS_EXTENDER device.
I need to implement the MSI-X in my driver. I have gone through so many posts and links.
From that what I should follow to achieve the MSI-X in KMDF is :

This is the basic idea which i have known so far. And also still I need clear understanding about this EvtInterruptIsr and EvtInterruptDpc callback functions.
As these callbacks are used to handle the device interrupts,what I should do here. Please if anyone knews about these callback function,make a brief note of it.

Well, you have to KNOW this. Every piece of hardware is different.
When your device fires an interrupt, it is trying to tell you
something. You have to figure out what it is trying to tell you, and
what you have to do in response to make it stop complaining.

If your hardware can do DMA, then maybe you get an interrupt when a DMA
operation has completed. In that case, then you may need to tell the
KMDF framework that the transfer is complete, or you may need to
complete the user-mode request that started the DMA operation in the
first place. If your hardware reports error conditions through
interrupts, then you have to decide what you’re going to do. Report it?
Blue screen?

There’s almost always a “pending interrupts” register in your hardware
that indicates what actually caused the interrupt. You’ll need to read
that to make sure it was really your hardware that fired the interrupt,
and you’ll need to clear that so the hardware stops interrupting.
Beyond that, every ISR is different.


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

Thanks for the response Tim…

As you said above those two callback function need to handle how that interrupt should be handled, I have also came across this EvtDeviceD0EntryPostInterruptsEnabled() callback function. This function is used to perform device specific operations that are required to perform after the interrupts has been enabled.

How this function differs from those two callback function…

Actually what my interrupt should do is, it should handle an event(error/completion notification).

So,which callback function should I use to handle this event.

xxxxx@gmail.com wrote:

As you said above those two callback function need to handle how that interrupt should be handled, I have also came across this EvtDeviceD0EntryPostInterruptsEnabled() callback function. This function is used to perform device specific operations that are required to perform after the interrupts has been enabled.

How this function differs from those two callback function…

I would hope that a few minutes of thinking would tell you the answer to
this.

The EvtDeviceD0EntryXxx callbacks are startup functions. They only get
called when power is applied to your device. EvtDeviceD0Entry gets
calls after power is applied but before interrupts are enabled.
EvtDeviceD0EntryPostInterruptsEnabled gets called after interrupts are
enabled. After that, neither one will ever be called again unless power
is removed. Most devices don’t need the PostInterruptsEnabled callback.

EvtInterruptIsr, on the other hand, gets called every time your device
raises an interrupt.

Actually what my interrupt should do is, it should handle an event(error/completion notification).

Yes, but what does that mean? What events? Which errors? You don’t
have to tell ME that, but you need to know every condition that can lead
to an interrupt, and you have to decide what to do in each case. For
some error conditions, there’s nothing you CAN do but clear the error,
but you have to make a conscious decision to do nothing.

Do you have a user-mode application that has sent you a notification
ioctl to be completed? That’s a common scheme. In that case, your ISR
fires off your DPC, and your DPC pulls the next waiting notification
request and completes it.

So,which callback function should I use to handle this event.

Seriously, you should be able to figure this out.


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

Thanks for the clear explanation Tim…

I will get back to you once I did implemented my EvtInterruptIsr() callback function and if I face any issues.