Custom USB Hub Driver

The project I am currently working on requires a driver to filter I/O to a USB hub. The hub has a control chip connected to one of its ports and the chip enumerates as a child device. The driver is supposed to control I/O as well as communicate with the control chip.

Is it possible to have the driver load the USB hub driver only when it detects the enumerated child with a specific USB vendor and product ID? Typically, you would use the USB vendor/product IDs of the hub to load the driver, but that option is not feasible for this project.

I have a feeling that this isn’t possible since you need the a USB driver to load before you can traverse the USB tree. The alternative solution I’ve come up with is creating 2 drivers and service. One driver would filter I/O to the hub, the other would communicate with the child control chip, and the service would connect the two together.

Any help would be greatly appreciated! Thanks.

xxxxx@gmail.com wrote:

The project I am currently working on requires a driver to filter I/O to a USB hub. The hub has a control chip connected to one of its ports and the chip enumerates as a child device. The driver is supposed to control I/O as well as communicate with the control chip.

Is it possible to have the driver load the USB hub driver only when it detects the enumerated child with a specific USB vendor and product ID? Typically, you would use the USB vendor/product IDs of the hub to load the driver, but that option is not feasible for this project.

What you’ve said here is that you want to suppress the hub if your
device is not in one of its ports. Is that correct? I hope you can see
that this is backwards. The hub will not even be asked to enumerate its
children unless the hub driver is already alive and well.

Without getting into too much detail, why can’t use use the VID/PID of
the hub? If the VID/PID of the hub has other uses, then how will you
decide that this system happens to be one where the child device is
required? What’s the danger if you leave the hub active?

The alternative solution I’ve come up with is creating 2 drivers and service. One driver would filter I/O to the hub, the other would communicate with the child control chip, and the service would connect the two together.

I don’t think you’ve thought through the use cases here. Let’s say you
put a device upper filter on your hub. What is that filter going to
do? You have to allow normal traffic to flow at least until all of its
children have enumerated, but how will you know that process is
completed? Once it is completed, if your child device was not present,
what will you do? Will you try to force a removal? Will you kill the
power?

And remember that it is trivially easy to remove a filter driver from a
device. If this is some kind of security scheme, you need to rethink
things.


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

Thanks for your response, Tim.

Yeah, I know this is completely backwards, but that was the way the device was designed. The VID/PID of the hub can’t be used because a decision was made to not control those values. Instead, I’m supposed to use the VID/PID of the chip to identify the device and work back up the tree, but that doesn’t make much sense to me.

Yes, this is a security scheme. Essentially, the control chip is supposed to enable the other ports on the hub. If the control chip does not enable the ports, the device is essentially dead/unusable. When the device is first plugged in, I would use the first driver to load for the enumerated control chip and enable the other ports while the hub would use the generic Windows driver. Once the ports are enabled, I would use the service to load the filter driver for the hub.

My apologies if this is confusing. I haven’t done much driver development and I’m sure if this even possible.

xxxxx@gmail.com wrote:

Yeah, I know this is completely backwards, but that was the way the device was designed. The VID/PID of the hub can’t be used because a decision was made to not control those values. Instead, I’m supposed to use the VID/PID of the chip to identify the device and work back up the tree, but that doesn’t make much sense to me.

For your next engineering design meeting, I would point out that the
behavior of a USB hub is dictated rather precisely by the USB
specification. You can’t just go around doing your own thing,
especially if you plan to put a USB logo on it. To get certified, it
has to behave like a USB device.

Yes, this is a security scheme. Essentially, the control chip is supposed to enable the other ports on the hub. If the control chip does not enable the ports, the device is essentially dead/unusable. When the device is first plugged in, I would use the first driver to load for the enumerated control chip and enable the other ports while the hub would use the generic Windows driver.

OK, so when the hub is first plugged in, it is a generic hub with one
active port. You plug in your Super Secret Decoder Ring Device (or
maybe it is wired in), which brings up your Decoder Ring Driver. That
driver somehow sends a vendor command to the hub that tells it to unlock
the other ports. Is that the principle? That would not be hard. The
hub is going to have to drop off of the bus and get re-enumerated to
have the additional ports be recognized. You can’t add ports to a hub
on the fly.

You wouldn’t even need a filter driver to make that work, but it assumes
that the hub has vendor commands to control the enable/disable state of
the other ports in hardware, and that it can re-enumerate itself.

Once the ports are enabled, I would use the service to load the filter driver for the hub.

Why do you need a filter driver? What does it bring to the party? And
if you don’t know the VID and PID, how would you know which hubs to filter?

My apologies if this is confusing. I haven’t done much driver development and I’m sure if this even possible.

This is not so much a driver development question as it is a hardware
design question.


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

On Wed, Apr 29, 2015 at 4:49 PM, Tim Roberts wrote:

> You can’t add ports to a hub
> on the fly
>

No, but you can indicate that nothing is connected to those ports and be
fully compliant with the spec. So the super-secret dongle thingy can
instruct the hub though a vendor command to enable the existing ports.

Mark Roddy