From: casyang on
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

From: Bill McKenzie on
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(a)gmail.com> wrote in message
news:1181047984.159030.204310(a)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
>


From: Bill McKenzie on
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(a)sbcglobal.net> wrote in message
news:OBsnHB4pHHA.3736(a)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(a)gmail.com> wrote in message
> news:1181047984.159030.204310(a)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
>>
>
>


From: casyang on
It's very useful for me. Thank you very much. - Casper

On 6 5 , 10 54 , "Bill McKenzie" <bkmcken...(a)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...(a)sbcglobal.net> wrote in message
>
> news:OBsnHB4pHHA.3736(a)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...(a)gmail.com> wrote in message
> >news:1181047984.159030.204310(a)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


From: Eliyas Yakub [MSFT] on
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