Dear all:

For filter drivers, KMDF automatically forwards the request to the
default I/O target (the next lower driver).

How to do this in PDO? Is there any option to do this?

I write two drivers: one for a bus driver to enumerate child device,
and another is for child device. I want to forward all child device
FDO request to bus driver FDO. So I need the function mentioned in
subject.

Thanks.

Casper

Re: For PDO: How to forward request to next lower driver stack automatically in KMDF? by Bill

Bill
Tue Jun 05 09:46:21 CDT 2007

First of all...the PDO is the bottom of the stack, you can't go lower. The
FDO for the bus driver is not in the same stack as the bus driver created
PDOs. They are the bottom of their own driver stack. In general, the PDO
should handle it's own requests and you shouldn't have to pass these on to
the bus driver's FDO. However, there are exceptions, IRP_MN_WAIT_WAKE is
not the least of these. In the case where you have to ebus driver's PDOs
and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
explicit pointer sharing between the two. There is an example of how to use
this in the WDK KMDF toaster bus driver sample.

Bill M.

<casyang@gmail.com> wrote in message
news:1181047984.159030.204310@a26g2000pre.googlegroups.com...
> Dear all:
>
> For filter drivers, KMDF automatically forwards the request to the
> default I/O target (the next lower driver).
>
> How to do this in PDO? Is there any option to do this?
>
> I write two drivers: one for a bus driver to enumerate child device,
> and another is for child device. I want to forward all child device
> FDO request to bus driver FDO. So I need the function mentioned in
> subject.
>
> Thanks.
>
> Casper
>



Re: For PDO: How to forward request to next lower driver stack automatically in KMDF? by Bill

Bill
Tue Jun 05 09:54:47 CDT 2007

This newsreader is f'ing up. The following sentence:

"In the case where you have to ebus driver's PDOs
and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
explicit pointer sharing between the two."

originally read:

"In the case where you have to communicate between the bus driver's PDOs
and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
explicit pointer sharing between the two."

Bill M.

"Bill McKenzie" <bkmckenzie@sbcglobal.net> wrote in message
news:OBsnHB4pHHA.3736@TK2MSFTNGP03.phx.gbl...
> First of all...the PDO is the bottom of the stack, you can't go lower.
> The FDO for the bus driver is not in the same stack as the bus driver
> created PDOs. They are the bottom of their own driver stack. In general,
> the PDO should handle it's own requests and you shouldn't have to pass
> these on to the bus driver's FDO. However, there are exceptions,
> IRP_MN_WAIT_WAKE is not the least of these. In the case where you have
> to ebus driver's PDOs and its FDO, you are best off using
> IRP_MN_QUERY_INTERFACE and setting up explicit pointer sharing between the
> two. There is an example of how to use this in the WDK KMDF toaster bus
> driver sample.
>
> Bill M.
>
> <casyang@gmail.com> wrote in message
> news:1181047984.159030.204310@a26g2000pre.googlegroups.com...
>> Dear all:
>>
>> For filter drivers, KMDF automatically forwards the request to the
>> default I/O target (the next lower driver).
>>
>> How to do this in PDO? Is there any option to do this?
>>
>> I write two drivers: one for a bus driver to enumerate child device,
>> and another is for child device. I want to forward all child device
>> FDO request to bus driver FDO. So I need the function mentioned in
>> subject.
>>
>> Thanks.
>>
>> Casper
>>
>
>



Re: For PDO: How to forward request to next lower driver stack automatically in KMDF? by casyang

casyang
Tue Jun 05 11:44:33 CDT 2007

It's very useful for me. Thank you very much. - Casper

On 6 5 , 10 54 , "Bill McKenzie" <bkmcken...@sbcglobal.net> wrote:
> This newsreader is f'ing up. The following sentence:
>
> "In the case where you have to ebus driver's PDOs
> and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
> explicit pointer sharing between the two."
>
> originally read:
>
> "In the case where you have to communicate between the bus driver's PDOs
> and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
> explicit pointer sharing between the two."
>
> Bill M.
>
> "Bill McKenzie" <bkmcken...@sbcglobal.net> wrote in message
>
> news:OBsnHB4pHHA.3736@TK2MSFTNGP03.phx.gbl...
>
> > First of all...the PDO is the bottom of the stack, you can't go lower.
> > The FDO for the bus driver is not in the same stack as the bus driver
> > created PDOs. They are the bottom of their own driver stack. In general,
> > the PDO should handle it's own requests and you shouldn't have to pass
> > these on to the bus driver's FDO. However, there are exceptions,
> > IRP_MN_WAIT_WAKE is not the least of these. In the case where you have
> > to ebus driver's PDOs and its FDO, you are best off using
> > IRP_MN_QUERY_INTERFACE and setting up explicit pointer sharing between the
> > two. There is an example of how to use this in the WDK KMDF toaster bus
> > driver sample.
>
> > Bill M.
>
> > <casy...@gmail.com> wrote in message
> >news:1181047984.159030.204310@a26g2000pre.googlegroups.com...
> >> Dear all:
>
> >> For filter drivers, KMDF automatically forwards the request to the
> >> default I/O target (the next lower driver).
>
> >> How to do this in PDO? Is there any option to do this?
>
> >> I write two drivers: one for a bus driver to enumerate child device,
> >> and another is for child device. I want to forward all child device
> >> FDO request to bus driver FDO. So I need the function mentioned in
> >> subject.
>
> >> Thanks.
>
> >> Casper



Re: For PDO: How to forward request to next lower driver stack automatically by Mark

Mark
Tue Jun 05 11:54:03 CDT 2007

Bill McKenzie wrote:
> This newsreader is f'ing up. The following sentence:
>
> "In the case where you have to ebus driver's PDOs
> and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
> explicit pointer sharing between the two."
>
> originally read:
>
> "In the case where you have to communicate between the bus driver's PDOs
> and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
> explicit pointer sharing between the two."
>
> Bill M.


The design that forwards PDO requests to the parent FDO is fairly
common. Offhand I am not sure I know why a function pointer interface is
necessarily better. One issue is obviously IRP stack allocations,
however whichever mechanism you use, an interface or forwarding the IRP
to the parent FDO, you have to deal with that problem.

WdfPdoGetParent gets a wdf handle to the parent FDO.
>
> "Bill McKenzie" <bkmckenzie@sbcglobal.net> wrote in message
> news:OBsnHB4pHHA.3736@TK2MSFTNGP03.phx.gbl...
>> First of all...the PDO is the bottom of the stack, you can't go lower.
>> The FDO for the bus driver is not in the same stack as the bus driver
>> created PDOs. They are the bottom of their own driver stack. In general,
>> the PDO should handle it's own requests and you shouldn't have to pass
>> these on to the bus driver's FDO. However, there are exceptions,
>> IRP_MN_WAIT_WAKE is not the least of these. In the case where you have
>> to ebus driver's PDOs and its FDO, you are best off using
>> IRP_MN_QUERY_INTERFACE and setting up explicit pointer sharing between the
>> two. There is an example of how to use this in the WDK KMDF toaster bus
>> driver sample.
>>
>> Bill M.
>>
>> <casyang@gmail.com> wrote in message
>> news:1181047984.159030.204310@a26g2000pre.googlegroups.com...
>>> Dear all:
>>>
>>> For filter drivers, KMDF automatically forwards the request to the
>>> default I/O target (the next lower driver).
>>>
>>> How to do this in PDO? Is there any option to do this?
>>>
>>> I write two drivers: one for a bus driver to enumerate child device,
>>> and another is for child device. I want to forward all child device
>>> FDO request to bus driver FDO. So I need the function mentioned in
>>> subject.
>>>
>>> Thanks.
>>>
>>> Casper
>>>
>>
>
>

Re: For PDO: How to forward request to next lower driver stack automatically in KMDF? by Eliyas

Eliyas
Tue Jun 05 12:48:04 CDT 2007

Instead of exchanging callback pointers between the PDO and parent FDO, you
can use IoTarget to forward the request from PDO to parent FDO. Currently
there isn't a sample in the WDK that shows how to do this but we have used
this scheme in couple of our MS drivers. In the future version of framework,
we might allow you to transfer request from the child PDO queue directly to
the parent FDO queue without using IoTarget.

So here are the steps on how to forward reqeust from PDO to parent FDO:

You do the steps 1-3 in the routine that creates the child PDO.

1) Get the wdm deviceobject pointer from the parent FDO.

PDEVICE_OBJECT parentWdmDeviceObject;

parentWdmDeviceObject =
WdfDeviceWdmGetDeviceObject(WdfPdoGetParent(hChild));

2) Increas the stack size of the PDO to account for the stack size of parent
FDO.

WdfDeviceWdmGetDeviceObject(hChild)->StackSize +=
parentWdmDeviceObject->StackSize;


3) Create an IoTarget and open the taget by using the deviceobject pointer
of parentWdmDeviceObject.

status = WdfIoTargetCreate(hChild,
WDF_NO_OBJECT_ATTRIBUTES,
&pdoData->IoTargetForParentFdo);
if (!NT_SUCCESS (status)) {
goto Cleanup;
}

WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE(&openParams,
parentWdmDeviceObject );

status = WdfIoTargetOpen(pdoData->IoTargetForParentFdo, &openParams);
if (!NT_SUCCESS (status)) {
goto Cleanup;
}

4) Use this iotarget to forward request. You can either forward in a
fire-and-forget manner or forward it with a completion routine. The
following routine shows how to forward reqeust from a default I/O handler of
PDO.

VOID
PdoEvtIoDefault(
IN WDFQUEUE Queue,
IN WDFREQUEST Request
)
{
NTSTATUS status;
BOOLEAN ret;
WDF_REQUEST_SEND_OPTIONS options;
PPDO_DEVICE_DATA pdoData;
WDFDEVICE device;

device = WdfIoQueueGetDevice(Queue);
pdoData = PdoGetData(device);

#ifdef FIRE_AND_FORGET

WDF_REQUEST_SEND_OPTIONS_INIT(&options,
WDF_REQUEST_SEND_OPTION_SEND_AND_FORGET);

ret = WdfRequestSend(Request,
pdoData->IoTargetForParentFdo,
&options);
#else

WdfRequestFormatRequestUsingCurrentType(Request);

WdfRequestSetCompletionRoutine(Request,
PdoRequestCompletionRoutine,
WDF_NO_CONTEXT);

ret = WdfRequestSend (Request, pdoData->IoTargetForParentFdo,
WDF_NO_SEND_OPTIONS);

#endif
if (ret == FALSE) {
status = WdfRequestGetStatus (Request);
KdPrint(("WdfRequestSend failed: 0x%x\n", status));
WdfRequestComplete(Request, status);
}
return;
}

VOID
PdoRequestCompletionRoutine(
IN WDFREQUEST Request,
IN WDFIOTARGET Target,
PWDF_REQUEST_COMPLETION_PARAMS CompletionParams,
IN WDFCONTEXT Context
)
{
UNREFERENCED_PARAMETER(Target);
UNREFERENCED_PARAMETER(Context);

WdfRequestComplete(Request, CompletionParams->IoStatus.Status);
return;
}


-Eliyas


Re: For PDO: How to forward request to next lower driver stack automatically in KMDF? by Bill

Bill
Tue Jun 05 21:39:35 CDT 2007

>One issue is obviously IRP stack allocations

Well actually I would suspect the bus would adjust the PDOs' stack sizes in
that case.

Your right all around...I wasn't thinking about I/O having to go to the
underlying bus. I was thinking about requests actually specific to that
stack.

Bill M.

"Mark Roddy" <markr@hollistech.com> wrote in message
news:ueychI5pHHA.1148@TK2MSFTNGP06.phx.gbl...
> Bill McKenzie wrote:
>> This newsreader is f'ing up. The following sentence:
>>
>> "In the case where you have to ebus driver's PDOs
>> and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
>> explicit pointer sharing between the two."
>>
>> originally read:
>>
>> "In the case where you have to communicate between the bus driver's PDOs
>> and its FDO, you are best off using IRP_MN_QUERY_INTERFACE and setting up
>> explicit pointer sharing between the two."
>>
>> Bill M.
>
>
> The design that forwards PDO requests to the parent FDO is fairly common.
> Offhand I am not sure I know why a function pointer interface is
> necessarily better. One issue is obviously IRP stack allocations, however
> whichever mechanism you use, an interface or forwarding the IRP to the
> parent FDO, you have to deal with that problem.
>
> WdfPdoGetParent gets a wdf handle to the parent FDO.
>>
>> "Bill McKenzie" <bkmckenzie@sbcglobal.net> wrote in message
>> news:OBsnHB4pHHA.3736@TK2MSFTNGP03.phx.gbl...
>>> First of all...the PDO is the bottom of the stack, you can't go lower.
>>> The FDO for the bus driver is not in the same stack as the bus driver
>>> created PDOs. They are the bottom of their own driver stack. In
>>> general, the PDO should handle it's own requests and you shouldn't have
>>> to pass these on to the bus driver's FDO. However, there are
>>> exceptions, IRP_MN_WAIT_WAKE is not the least of these. In the case
>>> where you have to ebus driver's PDOs and its FDO, you are best off using
>>> IRP_MN_QUERY_INTERFACE and setting up explicit pointer sharing between
>>> the two. There is an example of how to use this in the WDK KMDF toaster
>>> bus driver sample.
>>>
>>> Bill M.
>>>
>>> <casyang@gmail.com> wrote in message
>>> news:1181047984.159030.204310@a26g2000pre.googlegroups.com...
>>>> Dear all:
>>>>
>>>> For filter drivers, KMDF automatically forwards the request to the
>>>> default I/O target (the next lower driver).
>>>>
>>>> How to do this in PDO? Is there any option to do this?
>>>>
>>>> I write two drivers: one for a bus driver to enumerate child device,
>>>> and another is for child device. I want to forward all child device
>>>> FDO request to bus driver FDO. So I need the function mentioned in
>>>> subject.
>>>>
>>>> Thanks.
>>>>
>>>> Casper
>>>>
>>>
>>