an issue about the driver of PCIe devices

I have some PCIe data cards and their model and function is same .

I hope these cards just are a single windows device when their driver is loaded. In other words, No matter how many cards are inserted in the machine, we can just discover a singe device in windows device manager.

Can my idea be realized?
How can I design my driver?

thanks!

Where is Chris - I bet he is going to love this post…

Anton Bassov

By defaul each card shows up as its own instance. If the same driver controls all of the cards, the driver can expose them as one “device” using a fixed name symbolic link on a control device and then the driver manages all of the devices underneath

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@hotmail.com
Sent: Thursday, April 01, 2010 2:03 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] an issue about the driver of PCIe devices

I have some PCIe data cards and their model and function is same .

I hope these cards just are a single windows device when their driver is loaded. In other words, No matter how many cards are inserted in the machine, we can just discover a singe device in windows device manager.

Can my idea be realized?
How can I design my driver?

thanks!


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

anton bassov wrote:

Where is Chris - I bet he is going to love this post…

Well, I don’t think the OP is going to get exactly the behavior that he requests (only one device in Device Manager) without some “interesting” changes to the way the PCI bus enumerates devices…

But like Doron said, you can sort of accomplish the goal by having (say) one root-enumerated instance of the device through which all I/O is funneled, and this driver in turn forwards along the requests to the individual device instances.

Back in the day, we had a USB CDC ethernet driver, and whenever you plugged in a new device, you got a new networking card present, which of course changed the routing table as it was initialized. Well, we had some brain-dead VPN software which deemed any changes to the routing table while the VPN link was up as a “security risk” and immediately shut itself down.

One solution was to have a root-enumerated ethernet device that was “always” up, and would forward ethernet frames to a dummy driver attached to the USB device. If the device was not plugged in, the packets were just dropped on the floor…

Anyway, I’m sort of wondering why yongfan^2 wants to design his system this way…

> But like Doron said, you can sort of accomplish the goal by having (say) one root-enumerated

instance of the device through which all I/O is funneled, and this driver in turn forwards along
the requests to the individual device instances.

…however, this is not what the OP asks us about. Surely you can do it (in fact, your control device can be made
even not root-enumerated but just a “legacy” one), but this is not what the OP wants - after all, he made his goal very clear. This is why I found his post so funny…

Anton Bassov

Here was my response to a similar query (in another forum) a week or two
ago. You don’t say what sort of device yours is. This last query was about
a storage device. If you tell us more about your device, we may make
specific recommendations.

When you expose a function in PCI configuration space, you’re declaring that
it’s a completely independent entity, one which can be managed by our PCI
driver. This has to be the case, as the functions in a PCI device may be of
different types. (The laptop that I’m typing this on has a PCI device with
two Cardbus functions and one 1394 function.) Loading these different
software stacks on top of the functions requires that the PCI driver see
each function as a full-fledged device.

If the independent logic blocks inside your PCI device are not fully
independent, it’s not possible to correctly use our PCI driver to manage
them. You are welcome to provide your own bus driver and not use our PCI
driver, which allows you to manage those dependencies. But that requires
that you expose only a single PCI function to Windows.

If you have already created a device and brought it to market which has
multiple functions with cross-dependencies, you’re stuck. There’s no way to
get it working well. The best approximation of “working well” will come
from loading a bus driver on all your functions. This bus driver (not a
storport miniport) would have to wait until all the functions get started by
the PnP manager (and there will be no way to control the order in which that
happens) and then the bus driver can start enumerating pseudo-devices which
themselves are storport miniports. This will be complicated and costly to
build. It also probably won’t work well if you want to use it as the boot
device. It will definitely be hard to get crashdump working.


Jake Oshins
Hyper-V I/O Architect
Windows Kernel Group

This post implies no warranties and confers no rights.


wrote in message news:xxxxx@ntdev…
> I have some PCIe data cards and their model and function is same .
>
> I hope these cards just are a single windows device when their driver is
> loaded. In other words, No matter how many cards are inserted in the
> machine, we can just discover a singe device in windows device manager.
>
> Can my idea be realized?
> How can I design my driver?
>
> thanks!
>

wrote in message news:xxxxx@ntdev…

> Anyway, I’m sort of wondering why yongfan^2 wants to design his system
> this way…

Why not? This is like the kbd & mouse class drivers aggregate all input
devices.

– pa

dear Chris Aseltine and Doron Holan,

At present, My design is similar with your idea.

There are 2 drivers. One is a control driver and another is a function driver.
The function driver control data card, such as map\unmap register space, manage DMA data transfer, etc.

The control driver, which is a root-enumerated driver, communicates with function driver to conrol data cards to finish all kinds of commands.

But, I hope to merge the two drivers into a singe one(just named driverM.sys).
Then user can just discover a single device in OS, no matter how many cards are inserted in manchine practically. When user uses the device, “driverM.sys” will selects and controls each data card interanally. It seems that user is just using a single device.

The card is a data encryption\encryption PCIe card. Each card is independent and just has a singel funcion. By default, each card just has a same function driver in windows.

At present, these cards are used in Linux OS. No matter how many cards are inserted in machine, they are a single device for user and our Linux driver will manage these cards internally. So, I want to realize this design to windows.

Can you offer me some good recommendations?
thanks a lot!


Here was my response to a similar query (in another forum) a week or two
ago. You don’t say what sort of device yours is. This last query was about
a storage device. If you tell us more about your device, we may make
specific recommendations.

When you expose a function in PCI configuration space, you’re declaring that
it’s a completely independent entity, one which can be managed by our PCI
driver. This has to be the case, as the functions in a PCI device may be of
different types. (The laptop that I’m typing this on has a PCI device with
two Cardbus functions and one 1394 function.) Loading these different
software stacks on top of the functions requires that the PCI driver see
each function as a full-fledged device.

If the independent logic blocks inside your PCI device are not fully
independent, it’s not possible to correctly use our PCI driver to manage
them. You are welcome to provide your own bus driver and not use our PCI
driver, which allows you to manage those dependencies. But that requires
that you expose only a single PCI function to Windows.

If you have already created a device and brought it to market which has
multiple functions with cross-dependencies, you’re stuck. There’s no way to
get it working well. The best approximation of “working well” will come
from loading a bus driver on all your functions. This bus driver (not a
storport miniport) would have to wait until all the functions get started by
the PnP manager (and there will be no way to control the order in which that
happens) and then the bus driver can start enumerating pseudo-devices which
themselves are storport miniports. This will be complicated and costly to
build. It also probably won’t work well if you want to use it as the boot
device. It will definitely be hard to get crashdump working.


Jake Oshins
Hyper-V I/O Architect
Windows Kernel Group

This post implies no warranties and confers no rights.


wrote in message news:xxxxx@ntdev…
> I have some PCIe data cards and their model and function is same .
>
> I hope these cards just are a single windows device when their driver is
> loaded. In other words, No matter how many cards are inserted in the
> machine, we can just discover a singe device in windows device manager.
>
> Can my idea be realized?
> How can I design my driver?
>
> thanks!
<…excess quoted lines suppressed…>

Pavel A wrote:

Why not? This is like the kbd & mouse class drivers aggregate all
input devices.

I never said why not, I just said I was interested to hear his idea…

yongfan^2 wrote:

At present, these cards are used in Linux OS. No matter how many
cards are inserted in machine, they are a single device for user and
our Linux driver will manage these cards internally. So, I want to
realize this design to windows.

Can you offer me some good recommendations?

I think the approach that’s been discussed so far will probably work for you. Create a root-enumerated device that exposes a single interface (maybe even a named symbolic link) which accepts user I/O. Then use that driver to multiplex the communication/functionality out to the individual cards. Each individual PCI device can load a simple dummy driver or perhaps even a raw PDO which only serves to accept and forward requests to the card itself.

> At present, these cards are used in Linux OS. No matter how many cards are inserted in machine,

they are a single device for user

Really??? Are you saying that you will see just a single device if you run lspci??? Are you saying that you will see just a single device if you look under /sys/bus/pci_express/devices???

our Linux driver will manage these cards internally.

This, indeed, can be done pretty easily by exposing all these devices to the users as a single control device via /proc/devices, but it does not involve hiding these devices from PCI subsystem and/or from sysfs, does it…

So, I want to realize this design to windows.

Similarly, you can do it fairly easily under Windows the way Doron and Chris explained to you, but it does not involve hiding these devices from the Device Manager - if we translate your original question to Linux
world it would sound like “I want my PCI -e devices appear as a single one to PCI subsystem and sysfs”. This is why I found your question so funny…

Anton Bassov

Chris suggested a separate root enumerated device, i suggest that you just create a non pnp legacy control device without a root enumerated fake device. The control device reduces complexity since you do not need an installer to go create the root device and then manage it (and identify it at load time vs the real pci devices). The toaster filter sample shows how to create a control device in the first adddevice() call and how to destroy it on the last pnp remove.

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@hotmail.com
Sent: Friday, April 02, 2010 8:43 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] an issue about the driver of PCIe devices

I will study the example.
thanks a lot!


Chris suggested a separate root enumerated device, i suggest that you just
create a non pnp legacy control device without a root enumerated fake device.
The control device reduces complexity since you do not need an installer to go
create the root device and then manage it (and identify it at load time vs the
real pci devices). The toaster filter sample shows how to create a control
device in the first adddevice() call and how to destroy it on the last pnp
remove.

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@hotmail.com
Sent: Friday, April 02, 2010 8:43 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] an issue about the driver of PCIe devices

Yeah, I prepare to realize two drivers. One is a control driver and another is a function driver.

All the functions will be realized in control driver, such as ISR, the DPC routine of ISR, etc.
The control driver will be designed as an “EXPORT_DRIVER” one and export functions for function driver.

The function driver is just a dummy one and all the functions it registered will be called from control driver, such as ISR, the DPC of ISR , etc.

thanks a lot!


yongfan^2 wrote:

At present, these cards are used in Linux OS. No matter how many
cards are inserted in machine, they are a single device for user and
our Linux driver will manage these cards internally. So, I want to
realize this design to windows.

Can you offer me some good recommendations?

I think the approach that’s been discussed so far will probably work for you.
Create a root-enumerated device that exposes a single interface (maybe even a
named symbolic link) which accepts user I/O. Then use that driver to multiplex
the communication/functionality out to the individual cards. Each individual
PCI device can load a simple dummy driver or perhaps even a raw PDO which only
serves to accept and forward requests to the card itself.

thanks!


At present, these cards are used in Linux OS. No matter how many cards are
inserted in machine,
they are a single device for user

Really??? Are you saying that you will see just a single device if you run
lspci??? Are you saying that you will see just a single device if you look
under /sys/bus/pci_express/devices???

our Linux driver will manage these cards internally.

This, indeed, can be done pretty easily by exposing all these devices to the
users as a single control device via /proc/devices, but it does not involve
hiding these devices from PCI subsystem and/or from sysfs, does it…

So, I want to realize this design to windows.

Similarly, you can do it fairly easily under Windows the way Doron and Chris
explained to you, but it does not involve hiding these devices from the Device
Manager - if we translate your original question to Linux
world it would sound like “I want my PCI -e devices appear as a single one to
PCI subsystem and sysfs”. This is why I found your question so funny…

Anton Bassov