Is there an easier way to remove a WDFREQUEST from a WDFQUEUE?

As an alternative to the endless C/C++ thread, here’s a concrete question
for you WDF experts.

I want to complete a WDFREQEST. Simple, no?

WdfRequestCompleteWithInformation(Request, status, size);

Here’s an added wrinkle: It might or might not be in one of several
WDFQUEUEs. OK, so that appears to make it a lot bigger pain. Docs say
that I’m not just supposed to call WdfIoQueueRetrieveFoundRequest()
without calling WdfIoQueueFindRequest() first:

“Before calling WdfIoQueueRetrieveFoundRequest, the driver must call
WdfIoQueueFindRequest, which retrieves a handle that the driver can use as
the FoundRequest parameter to WdfIoQueueRetrieveFoundRequest.”

Empirically, just calling WdfIoQueueRetrieveFoundRequest directly on the
Request handed to me without calling WdfIoQueueFindRequest works OK. Are
the docs being overly cautionary here?

Additionally, calling WdfIoQueueFindRequest() with NULL for the
PWDF_REQUEST_PARAMETERS and passing in the WDFREQUEST I’m looking for
results in NOT_FOUND, which makes sense, as it starts the search from
there. The WdfIoQueueFindRequest() prototype says that the
PWDF_REQUEST_PARAMETERS is an OUT, not an in, and the doc page is mixed.
About the parameter itself, the doc says that it does indeed return the
parameters of the found request. Why? I can just get them from the
request. The description of WdfIoQueueFindRequest() says, “If
FoundRequest is NULL, this method locates the first request in the I/O
queue that matches the FileObject and Parameters values.” That sounds
like the PWDF_REQUEST_PARAMETERS parameter is actually an input. Then it
goes on to say, “If Parameters is not NULL, this method copies the found
request’s parameters into the driver-supplied structure.” So that
certainly looks like an output. Perhaps it’s an IN OUT?

Anyway, this seems like a lot of pain to get ownership of a request I
already have. Did I make it hard on myself, or did the WDF team miss this
use case?

WDF_REQUEST_PARAMETERS parms;
WDFREQUEST finder;

NTSTATUS status;
WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);

if(reqQueue)
{
WDF_REQUEST_PARAMETERS_INIT(&parms);
WdfRequestGetParameters(Request, &parms);
// Is parms really an output like the prototype says, or an input like
// the doc description says?
status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms, &finder);
if(NT_SUCCESS(status))
{
status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
&Request);
// Doc says I need to do this…
WdfObjectDereference(finder);
if(NT_SUCCESS(status))
{
WdfRequestCompleteWithInformation(Request, status, size);
}
}
}
else // Just complete the request.
{
WdfRequestCompleteWithInformation(request, (NTSTATUS)osStatus, size);
}

Anyone have any clarity to offer?

Thanks,

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

xxxxx@seagate.com wrote:

WDF_REQUEST_PARAMETERS parms;
WDFREQUEST finder;

NTSTATUS status;
WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);

if(reqQueue)
{
WDF_REQUEST_PARAMETERS_INIT(&parms);
WdfRequestGetParameters(Request, &parms);
// Is parms really an output like the prototype says, or an input
like
// the doc description says?
status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
&finder);
if(NT_SUCCESS(status))
{
status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
&Request);
// Doc says I need to do this…
WdfObjectDereference(finder);

That can’t be right. “finder” is uninitialized at this point.


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

Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

WDF_REQUEST_PARAMETERS parms;
WDFREQUEST finder;

NTSTATUS status;
WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);

if(reqQueue)
{
WDF_REQUEST_PARAMETERS_INIT(&parms);
WdfRequestGetParameters(Request, &parms);
// Is parms really an output like the prototype says, or an input
like
// the doc description says?
status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
&finder);
if(NT_SUCCESS(status))
{
status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
&Request);
// Doc says I need to do this…
WdfObjectDereference(finder);

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Tim Roberts wrote:

xxxxx@seagate.com wrote:

>WDF_REQUEST_PARAMETERS parms;
>WDFREQUEST finder;
>
>NTSTATUS status;
>WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
>if(reqQueue)
>{
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
>like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
>&finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
>&Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>
>
>

That can’t be right. “finder” is uninitialized at this point.

Whoops, color me unobservant. I see it now at line N-5.


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

So you have a request, you’ve forwarded into some queue, and now you
want to complete it in a race with its being presented to the driver
callback, cancelled, etc…?

Can you explain a little more about how your driver gets into this
situation. The theory has been that the driver should know where a
request is when it’s time to complete it.

-p


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Friday, April 28, 2006 4:04 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

As an alternative to the endless C/C++ thread, here’s a concrete
question for you WDF experts.

I want to complete a WDFREQEST. Simple, no?

WdfRequestCompleteWithInformation(Request, status, size);

Here’s an added wrinkle: It might or might not be in one of several
WDFQUEUEs. OK, so that appears to make it a lot bigger pain. Docs say
that I’m not just supposed to call WdfIoQueueRetrieveFoundRequest()
without calling WdfIoQueueFindRequest() first:

“Before calling WdfIoQueueRetrieveFoundRequest, the driver must call
WdfIoQueueFindRequest, which retrieves a handle that the driver can use
as the FoundRequest parameter to WdfIoQueueRetrieveFoundRequest.”

Empirically, just calling WdfIoQueueRetrieveFoundRequest directly on the
Request handed to me without calling WdfIoQueueFindRequest works OK.
Are the docs being overly cautionary here?

Additionally, calling WdfIoQueueFindRequest() with NULL for the
PWDF_REQUEST_PARAMETERS and passing in the WDFREQUEST I’m looking for
results in NOT_FOUND, which makes sense, as it starts the search from
there. The WdfIoQueueFindRequest() prototype says that the
PWDF_REQUEST_PARAMETERS is an OUT, not an in, and the doc page is mixed.
About the parameter itself, the doc says that it does indeed return the
parameters of the found request. Why? I can just get them from the
request. The description of WdfIoQueueFindRequest() says, “If
FoundRequest is NULL, this method locates the first request in the I/O
queue that matches the FileObject and Parameters values.” That sounds
like the PWDF_REQUEST_PARAMETERS parameter is actually an input. Then
it goes on to say, “If Parameters is not NULL, this method copies the
found request’s parameters into the driver-supplied structure.” So that
certainly looks like an output. Perhaps it’s an IN OUT?

Anyway, this seems like a lot of pain to get ownership of a request I
already have. Did I make it hard on myself, or did the WDF team miss
this use case?

WDF_REQUEST_PARAMETERS parms;
WDFREQUEST finder;

NTSTATUS status;
WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);

if(reqQueue)
{
WDF_REQUEST_PARAMETERS_INIT(&parms);
WdfRequestGetParameters(Request, &parms);
// Is parms really an output like the prototype says, or an input
like
// the doc description says?
status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
&finder);
if(NT_SUCCESS(status))
{
status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
&Request);
// Doc says I need to do this…
WdfObjectDereference(finder);
if(NT_SUCCESS(status))
{
WdfRequestCompleteWithInformation(Request, status, size);
}
}
}
else // Just complete the request.
{
WdfRequestCompleteWithInformation(request, (NTSTATUS)osStatus, size);

}

Anyone have any clarity to offer?

Thanks,

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Yes, it is a manual queue. We’ve (mostly) implemented the WDF version of
Extreme DMA in a lab test harness. We use one manual queue for reqs when
they are ready to start, and another one for reqs that have been started.

There isn’t an issue with the queue we use to keep the ready reqs, since we
just pull the next one off the front. We’re only using the in-progress
queue as a cancellation container. Perhaps we should rethink that and just
use WdfRequestMarkCancellable? Seems like that would simplify things a lot.

Thanks,

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

> WDF_REQUEST_PARAMETERS parms;
> WDFREQUEST finder;
>
> NTSTATUS status;
> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
> if(reqQueue)
> {
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
> like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
> &finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
> &Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I think you need to use the queue’s OnCancel callback (don’t remember
the exact name & no DDK in front of me) … I don’t think you can insert
a cancellable request into a queue. Either way it will probably be
easier than (I presume) registring your own WDM cancel routine and then
trying to find the request after the fact.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Phil Barila
Sent: Saturday, April 29, 2006 9:13 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Yes, it is a manual queue. We’ve (mostly) implemented the WDF version
of Extreme DMA in a lab test harness. We use one manual queue for reqs
when they are ready to start, and another one for reqs that have been
started.

There isn’t an issue with the queue we use to keep the ready reqs, since
we just pull the next one off the front. We’re only using the
in-progress queue as a cancellation container. Perhaps we should
rethink that and just use WdfRequestMarkCancellable? Seems like that
would simplify things a lot.

Thanks,

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

> WDF_REQUEST_PARAMETERS parms;
> WDFREQUEST finder;
>
> NTSTATUS status;
> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
> if(reqQueue)
> {
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
> like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
> &finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
> &Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

If the request has already been canceled and completed, it doesn’t have
a current queue and that first call will fail. You can store the
current queue in the request context and try to retrieve the request
that way from the queue, but I think you need to track things a bit
better and know the state of the request when you are operating on it.

There are 2 cancel routines. The first is the per request cancel
routine for a request presented to the driver (WdfRequestMarkCancellable
sets it). There is also callback on the queue itself for requests
pushed into the queue that are canceled before they can be presented to
the driver. This callback is only for requests that the driver has seen
before (so you had it in queue A and fwd’ed it to queue B and it got
canceled on B before B could present it back again). This callback is
called EvtIoCanceledOnQueue and is set on a per queue basis in the queue
config when it is created.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Sunday, April 30, 2006 9:07 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

I think you need to use the queue’s OnCancel callback (don’t remember
the exact name & no DDK in front of me) … I don’t think you can insert
a cancellable request into a queue. Either way it will probably be
easier than (I presume) registring your own WDM cancel routine and then
trying to find the request after the fact.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Phil Barila
Sent: Saturday, April 29, 2006 9:13 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Yes, it is a manual queue. We’ve (mostly) implemented the WDF version
of Extreme DMA in a lab test harness. We use one manual queue for reqs
when they are ready to start, and another one for reqs that have been
started.

There isn’t an issue with the queue we use to keep the ready reqs, since
we just pull the next one off the front. We’re only using the
in-progress queue as a cancellation container. Perhaps we should
rethink that and just use WdfRequestMarkCancellable? Seems like that
would simplify things a lot.

Thanks,

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

> WDF_REQUEST_PARAMETERS parms;
> WDFREQUEST finder;
>
> NTSTATUS status;
> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
> if(reqQueue)
> {
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
> like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
> &finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
> &Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Doron and Peter,

Thanks for the responses.

A couple of things that might color your answers.

First, we do have a cancellation callback on the WDFQUEUEs, even the
manual ones. So cancellation isn’t the problem. Since we support Out Of
Order completion, dequeuing in the success completion path is the pain.
That’s what the code below is, and that’s all that it is. Is there a
better way to take a request out of an arbitrary location in the queue
than what I have below?

The first call (WdfRequestGetIoQueue) is not part of the pain. It’s clear
and simple. It was simply a convenience to use that in this routine
rather than to “track things a bit better”. I do know which Q the reqs
are in.

At the risk of repeating myself, I’ll restate the real problem, which is
what we’re always telling all the newbies:

Assuming that an arbitrary WDFREQUEST is in an arbitrary location in a
manual WDFQUEUE, what is the optimal way to remove that WDFREQUEST from
that WDFQUEUE so the WDFREQUEST can be completed without corrupting the
manual WDFQUEUE? Is there an alternative to using a manual WDFQUEUE for a
cancellation container that supports Out Of Order completion?

Seems like the answer is to use my own container and use
WdfRequestMarkCancelable.

I’d really like to know if I missed some coolness in the WDFQUEUE usage
that supports what I need to do without having to call GetParameters,
FindFirst, FindClose just to call a Remove on a WDFREQUEST I already have,
but don’t own, because the WDFQUEUE still owns it.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Sunday, April 30, 2006 11:39 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

If the request has already been canceled and completed, it doesn’t have
a current queue and that first call will fail. You can store the
current queue in the request context and try to retrieve the request
that way from the queue, but I think you need to track things a bit
better and know the state of the request when you are operating on it.

There are 2 cancel routines. The first is the per request cancel
routine for a request presented to the driver (WdfRequestMarkCancellable
sets it). There is also callback on the queue itself for requests
pushed into the queue that are canceled before they can be presented to
the driver. This callback is only for requests that the driver has seen
before (so you had it in queue A and fwd’ed it to queue B and it got
canceled on B before B could present it back again). This callback is
called EvtIoCanceledOnQueue and is set on a per queue basis in the queue
config when it is created.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Sunday, April 30, 2006 9:07 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

I think you need to use the queue’s OnCancel callback (don’t remember
the exact name & no DDK in front of me) … I don’t think you can insert
a cancellable request into a queue. Either way it will probably be
easier than (I presume) registring your own WDM cancel routine and then
trying to find the request after the fact.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Phil Barila
Sent: Saturday, April 29, 2006 9:13 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Yes, it is a manual queue. We’ve (mostly) implemented the WDF version
of Extreme DMA in a lab test harness. We use one manual queue for reqs
when they are ready to start, and another one for reqs that have been
started.

There isn’t an issue with the queue we use to keep the ready reqs, since
we just pull the next one off the front. We’re only using the
in-progress queue as a cancellation container. Perhaps we should
rethink that and just use WdfRequestMarkCancellable? Seems like that
would simplify things a lot.

Thanks,

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

> WDF_REQUEST_PARAMETERS parms;
> WDFREQUEST finder;
>
> NTSTATUS status;
> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
> if(reqQueue)
> {
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
> like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
> &finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
> &Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

You enumerate the queue looking for the request you want to complete by
calling WdfIoQueueFindRequest. Once you find the request, you retrieve
it by calling WdfIoQueueRetrieveFoundRequest.

NICGetIoctlRequest function in the PCIDRV sample describes how to use
these two functions.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 9:16 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Doron and Peter,

Thanks for the responses.

A couple of things that might color your answers.

First, we do have a cancellation callback on the WDFQUEUEs, even the
manual ones. So cancellation isn’t the problem. Since we support Out
Of
Order completion, dequeuing in the success completion path is the pain.
That’s what the code below is, and that’s all that it is. Is there a
better way to take a request out of an arbitrary location in the queue
than what I have below?

The first call (WdfRequestGetIoQueue) is not part of the pain. It’s
clear
and simple. It was simply a convenience to use that in this routine
rather than to “track things a bit better”. I do know which Q the reqs
are in.

At the risk of repeating myself, I’ll restate the real problem, which is
what we’re always telling all the newbies:

Assuming that an arbitrary WDFREQUEST is in an arbitrary location in a
manual WDFQUEUE, what is the optimal way to remove that WDFREQUEST from
that WDFQUEUE so the WDFREQUEST can be completed without corrupting the
manual WDFQUEUE? Is there an alternative to using a manual WDFQUEUE for
a
cancellation container that supports Out Of Order completion?

Seems like the answer is to use my own container and use
WdfRequestMarkCancelable.

I’d really like to know if I missed some coolness in the WDFQUEUE usage
that supports what I need to do without having to call GetParameters,
FindFirst, FindClose just to call a Remove on a WDFREQUEST I already
have,
but don’t own, because the WDFQUEUE still owns it.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Sunday, April 30, 2006 11:39 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

If the request has already been canceled and completed, it doesn’t have
a current queue and that first call will fail. You can store the
current queue in the request context and try to retrieve the request
that way from the queue, but I think you need to track things a bit
better and know the state of the request when you are operating on it.

There are 2 cancel routines. The first is the per request cancel
routine for a request presented to the driver (WdfRequestMarkCancellable
sets it). There is also callback on the queue itself for requests
pushed into the queue that are canceled before they can be presented to
the driver. This callback is only for requests that the driver has seen
before (so you had it in queue A and fwd’ed it to queue B and it got
canceled on B before B could present it back again). This callback is
called EvtIoCanceledOnQueue and is set on a per queue basis in the queue
config when it is created.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Sunday, April 30, 2006 9:07 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

I think you need to use the queue’s OnCancel callback (don’t remember
the exact name & no DDK in front of me) … I don’t think you can insert
a cancellable request into a queue. Either way it will probably be
easier than (I presume) registring your own WDM cancel routine and then
trying to find the request after the fact.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Phil Barila
Sent: Saturday, April 29, 2006 9:13 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Yes, it is a manual queue. We’ve (mostly) implemented the WDF version
of Extreme DMA in a lab test harness. We use one manual queue for reqs
when they are ready to start, and another one for reqs that have been
started.

There isn’t an issue with the queue we use to keep the ready reqs, since
we just pull the next one off the front. We’re only using the
in-progress queue as a cancellation container. Perhaps we should
rethink that and just use WdfRequestMarkCancellable? Seems like that
would simplify things a lot.

Thanks,

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

> WDF_REQUEST_PARAMETERS parms;
> WDFREQUEST finder;
>
> NTSTATUS status;
> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
> if(reqQueue)
> {
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
> like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
> &finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
> &Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Doron,

In other words, in order to do out of order completion on a manual
WDFQUEUE, you have to perform the logical equivalent of
FindFirst/FindNext/FindClose until you match the WDFREQUEST value you are
looking for. No thanks, there is not near enough value in using the Q as
a cancellation container, which is the only thing we used it for, to merit
that much hassle. It’s just cleaner to use our own container and
MarkCancelable/UnmarkCancelable in our architecture.

Thanks for confirming my suspicions.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, May 01, 2006 11:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

You enumerate the queue looking for the request you want to complete by
calling WdfIoQueueFindRequest. Once you find the request, you retrieve
it by calling WdfIoQueueRetrieveFoundRequest.

NICGetIoctlRequest function in the PCIDRV sample describes how to use
these two functions.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 9:16 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Doron and Peter,

Thanks for the responses.

A couple of things that might color your answers.

First, we do have a cancellation callback on the WDFQUEUEs, even the
manual ones. So cancellation isn’t the problem. Since we support Out
Of
Order completion, dequeuing in the success completion path is the pain.
That’s what the code below is, and that’s all that it is. Is there a
better way to take a request out of an arbitrary location in the queue
than what I have below?

The first call (WdfRequestGetIoQueue) is not part of the pain. It’s
clear
and simple. It was simply a convenience to use that in this routine
rather than to “track things a bit better”. I do know which Q the reqs
are in.

At the risk of repeating myself, I’ll restate the real problem, which is
what we’re always telling all the newbies:

Assuming that an arbitrary WDFREQUEST is in an arbitrary location in a
manual WDFQUEUE, what is the optimal way to remove that WDFREQUEST from
that WDFQUEUE so the WDFREQUEST can be completed without corrupting the
manual WDFQUEUE? Is there an alternative to using a manual WDFQUEUE for
a
cancellation container that supports Out Of Order completion?

Seems like the answer is to use my own container and use
WdfRequestMarkCancelable.

I’d really like to know if I missed some coolness in the WDFQUEUE usage
that supports what I need to do without having to call GetParameters,
FindFirst, FindClose just to call a Remove on a WDFREQUEST I already
have,
but don’t own, because the WDFQUEUE still owns it.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Sunday, April 30, 2006 11:39 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

If the request has already been canceled and completed, it doesn’t have
a current queue and that first call will fail. You can store the
current queue in the request context and try to retrieve the request
that way from the queue, but I think you need to track things a bit
better and know the state of the request when you are operating on it.

There are 2 cancel routines. The first is the per request cancel
routine for a request presented to the driver (WdfRequestMarkCancellable
sets it). There is also callback on the queue itself for requests
pushed into the queue that are canceled before they can be presented to
the driver. This callback is only for requests that the driver has seen
before (so you had it in queue A and fwd’ed it to queue B and it got
canceled on B before B could present it back again). This callback is
called EvtIoCanceledOnQueue and is set on a per queue basis in the queue
config when it is created.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Sunday, April 30, 2006 9:07 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

I think you need to use the queue’s OnCancel callback (don’t remember
the exact name & no DDK in front of me) … I don’t think you can insert
a cancellable request into a queue. Either way it will probably be
easier than (I presume) registring your own WDM cancel routine and then
trying to find the request after the fact.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Phil Barila
Sent: Saturday, April 29, 2006 9:13 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Yes, it is a manual queue. We’ve (mostly) implemented the WDF version
of Extreme DMA in a lab test harness. We use one manual queue for reqs
when they are ready to start, and another one for reqs that have been
started.

There isn’t an issue with the queue we use to keep the ready reqs, since
we just pull the next one off the front. We’re only using the
in-progress queue as a cancellation container. Perhaps we should
rethink that and just use WdfRequestMarkCancellable? Seems like that
would simplify things a lot.

Thanks,

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

> WDF_REQUEST_PARAMETERS parms;
> WDFREQUEST finder;
>
> NTSTATUS status;
> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
> if(reqQueue)
> {
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
> like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
> &finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
> &Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

WdfIoQueueFindRequest will look for a specific request if you hand it
the reqeust handle. Think of it as referencing the request for your iff
it hasn’t yet been cancelled or completed.

So you don’t need to iterate through the queue. You can make a single
call.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 1:14 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Doron,

In other words, in order to do out of order completion on a manual
WDFQUEUE, you have to perform the logical equivalent of
FindFirst/FindNext/FindClose until you match the WDFREQUEST value you
are looking for. No thanks, there is not near enough value in using the
Q as a cancellation container, which is the only thing we used it for,
to merit that much hassle. It’s just cleaner to use our own container
and MarkCancelable/UnmarkCancelable in our architecture.

Thanks for confirming my suspicions.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, May 01, 2006 11:54 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

You enumerate the queue looking for the request you want to complete by
calling WdfIoQueueFindRequest. Once you find the request, you retrieve
it by calling WdfIoQueueRetrieveFoundRequest.

NICGetIoctlRequest function in the PCIDRV sample describes how to use
these two functions.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 9:16 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Doron and Peter,

Thanks for the responses.

A couple of things that might color your answers.

First, we do have a cancellation callback on the WDFQUEUEs, even the
manual ones. So cancellation isn’t the problem. Since we support Out
Of Order completion, dequeuing in the success completion path is the
pain.
That’s what the code below is, and that’s all that it is. Is there a
better way to take a request out of an arbitrary location in the queue
than what I have below?

The first call (WdfRequestGetIoQueue) is not part of the pain. It’s
clear and simple. It was simply a convenience to use that in this
routine rather than to “track things a bit better”. I do know which Q
the reqs are in.

At the risk of repeating myself, I’ll restate the real problem, which is
what we’re always telling all the newbies:

Assuming that an arbitrary WDFREQUEST is in an arbitrary location in a
manual WDFQUEUE, what is the optimal way to remove that WDFREQUEST from
that WDFQUEUE so the WDFREQUEST can be completed without corrupting the
manual WDFQUEUE? Is there an alternative to using a manual WDFQUEUE for
a cancellation container that supports Out Of Order completion?

Seems like the answer is to use my own container and use
WdfRequestMarkCancelable.

I’d really like to know if I missed some coolness in the WDFQUEUE usage
that supports what I need to do without having to call GetParameters,
FindFirst, FindClose just to call a Remove on a WDFREQUEST I already
have, but don’t own, because the WDFQUEUE still owns it.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Sunday, April 30, 2006 11:39 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

If the request has already been canceled and completed, it doesn’t have
a current queue and that first call will fail. You can store the
current queue in the request context and try to retrieve the request
that way from the queue, but I think you need to track things a bit
better and know the state of the request when you are operating on it.

There are 2 cancel routines. The first is the per request cancel
routine for a request presented to the driver (WdfRequestMarkCancellable
sets it). There is also callback on the queue itself for requests
pushed into the queue that are canceled before they can be presented to
the driver. This callback is only for requests that the driver has seen
before (so you had it in queue A and fwd’ed it to queue B and it got
canceled on B before B could present it back again). This callback is
called EvtIoCanceledOnQueue and is set on a per queue basis in the queue
config when it is created.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Sunday, April 30, 2006 9:07 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

I think you need to use the queue’s OnCancel callback (don’t remember
the exact name & no DDK in front of me) … I don’t think you can insert
a cancellable request into a queue. Either way it will probably be
easier than (I presume) registring your own WDM cancel routine and then
trying to find the request after the fact.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Phil Barila
Sent: Saturday, April 29, 2006 9:13 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Yes, it is a manual queue. We’ve (mostly) implemented the WDF version
of Extreme DMA in a lab test harness. We use one manual queue for reqs
when they are ready to start, and another one for reqs that have been
started.

There isn’t an issue with the queue we use to keep the ready reqs, since
we just pull the next one off the front. We’re only using the
in-progress queue as a cancellation container. Perhaps we should
rethink that and just use WdfRequestMarkCancellable? Seems like that
would simplify things a lot.

Thanks,

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
Find request is only for a manual queue. If you are using other types
of queues then you don’t need to find/retrieve it. You can just
complete the request (assuming you have removed any cancel routine you
have previously set).

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Friday, April 28, 2006 4:42 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

xxxxx@seagate.com wrote:

> WDF_REQUEST_PARAMETERS parms;
> WDFREQUEST finder;
>
> NTSTATUS status;
> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>
> if(reqQueue)
> {
> WDF_REQUEST_PARAMETERS_INIT(&parms);
> WdfRequestGetParameters(Request, &parms);
> // Is parms really an output like the prototype says, or an input
> like
> // the doc description says?
> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
> &finder);
> if(NT_SUCCESS(status))
> {
> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
> &Request);
> // Doc says I need to do this…
> WdfObjectDereference(finder);
>

That can’t be right. “finder” is uninitialized at this point.


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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Peter,

I tried WdfIoQueueFindRequest with the WDFREQUEST I was looking for. The
req wasn’t found, and I know it hadn’t been cancelled or completed yet.
And it makes sense. The WDFREQUEST parameter to WdfIoQueueFindRequest is
labeled Previous for a reason, and that is that it’s documented as the
starting point for a search. Although I don’t have a clue how it’s
implemented, it appears from external evidence that WdfIoQueueFindRequest
assumes that its only usage model is the FindFirst/FindNext/FindClose
model. It doesn’t appear to be capable of returning the Request you
already have.

If I already have a WDFREQUEST, and I know which WDFQUEUE it’s in, the
logical thing to do would be to simply do a
WdfIoQueueRemoveRequest(WDFQUEUE Queue, WDFREQUEST Request), don’t you
think?

Too bad there isn’t one of those. The closest thing to that is
WdfIoQueueRetrieveFoundRequest().

Although calling WdfIoQueueRetrieveFoundRequest() with the WDFREQUEST I
already have appears to work safely in this generation of WDF, the docs
clearly say that you need to do WdfIoQueueFindRequest first, and don’t
forget to dereference the find handle when you are done. Hence my
reluctance to use it, since it adds a lot of code overhead to a very
simple operation.

Peter, I appreciate that “all WDF, all the time” is desirable, but let’s
face an inescapable fact: WDFQUEUEs weren’t designed to be used as
vectors, they were designed primarily as single-ended queues, and using
them that way works very well. Trying to use them as a vector, which is
really what we were doing, is stretching the utility of the WDFQUEUE
beyond where it is equipped to go without serious usability compromises.
So I don’t offer much of a criticism of the WDFQUEUE, it would be nice if
it were more conveniently used as a vector, but it’s not, and I assume
that wasn’t part of the design requirement.

Allow me to append the caveat that I might be horribly misunderstanding
the WDFQUEUE model badly, but since both you and Doron both have said “Use
WdfIoQueueFindRequest()”, I doubt that I’m completely out in the weeds, so
I think my analysis is reasonably sound. Please correct me where
appropriate.

Thanks,

BTW, I implemented the Mark/UnmarkCancelable and EvtRequestCancel callback
in about 10 lines of real code, plus liberal comments. In our
environment, that was clearly the way to go. If the WDFQUEUE didn’t have
the ugly overhead involved, it would have been a wash, and I would have
left it the way it was.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, May 01, 2006 2:59 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

WdfIoQueueFindRequest will look for a specific request if you hand it
the reqeust handle. Think of it as referencing the request for your iff
it hasn’t yet been cancelled or completed.

So you don’t need to iterate through the queue. You can make a single
call.

-p

Why do you need a manual queue at all? Just park all of your requeusts
in a non sequential queue. Since you are already tracking the
wdfrequest separately, you just shove the request into the queue,
(optionally) set the cancel routine and then complete the request when
it is done (removing the optional cancel routine first if needed). If
you just need a container of requests that handles cancellation for you,
this is the way to go.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 3:45 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Peter,

I tried WdfIoQueueFindRequest with the WDFREQUEST I was looking for.
The
req wasn’t found, and I know it hadn’t been cancelled or completed yet.
And it makes sense. The WDFREQUEST parameter to WdfIoQueueFindRequest
is
labeled Previous for a reason, and that is that it’s documented as the
starting point for a search. Although I don’t have a clue how it’s
implemented, it appears from external evidence that
WdfIoQueueFindRequest
assumes that its only usage model is the FindFirst/FindNext/FindClose
model. It doesn’t appear to be capable of returning the Request you
already have.

If I already have a WDFREQUEST, and I know which WDFQUEUE it’s in, the
logical thing to do would be to simply do a
WdfIoQueueRemoveRequest(WDFQUEUE Queue, WDFREQUEST Request), don’t you
think?

Too bad there isn’t one of those. The closest thing to that is
WdfIoQueueRetrieveFoundRequest().

Although calling WdfIoQueueRetrieveFoundRequest() with the WDFREQUEST I
already have appears to work safely in this generation of WDF, the docs
clearly say that you need to do WdfIoQueueFindRequest first, and don’t
forget to dereference the find handle when you are done. Hence my
reluctance to use it, since it adds a lot of code overhead to a very
simple operation.

Peter, I appreciate that “all WDF, all the time” is desirable, but let’s
face an inescapable fact: WDFQUEUEs weren’t designed to be used as
vectors, they were designed primarily as single-ended queues, and using
them that way works very well. Trying to use them as a vector, which is
really what we were doing, is stretching the utility of the WDFQUEUE
beyond where it is equipped to go without serious usability compromises.
So I don’t offer much of a criticism of the WDFQUEUE, it would be nice
if
it were more conveniently used as a vector, but it’s not, and I assume
that wasn’t part of the design requirement.

Allow me to append the caveat that I might be horribly misunderstanding
the WDFQUEUE model badly, but since both you and Doron both have said
“Use
WdfIoQueueFindRequest()”, I doubt that I’m completely out in the weeds,
so
I think my analysis is reasonably sound. Please correct me where
appropriate.

Thanks,

BTW, I implemented the Mark/UnmarkCancelable and EvtRequestCancel
callback
in about 10 lines of real code, plus liberal comments. In our
environment, that was clearly the way to go. If the WDFQUEUE didn’t
have
the ugly overhead involved, it would have been a wash, and I would have
left it the way it was.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, May 01, 2006 2:59 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

WdfIoQueueFindRequest will look for a specific request if you hand it
the reqeust handle. Think of it as referencing the request for your iff
it hasn’t yet been cancelled or completed.

So you don’t need to iterate through the queue. You can make a single
call.

-p


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I’ve been writing WDF/KMDF drivers for about three years now. My first
thought was about like yours. Leave a WDFREQUEST in a queue while I’m
operating on it to make cancelation and organization simple.

What I’ve discovered in those three years is that just isn’t what WDF queues
were meant for. Today, I only use WDF queues for requests that I have not
started any processing on. As soon as I start, it comes out of the queue
and goes onto one of several work lists. If appropriate, it also becomes
cancellable by calling WdfRequestMarkCancellable.

Incidentally, as I started to make this realization, I started putting my
in-progress requests into collections. I stopped doing that, too, as the
collection API can fail, greatly complicating my state management. I now
use plain old linked lists in the request contexts.


Jake Oshins
Windows Kernel Group

The Virtual Machine Team at Microsoft is hiring. Contact
xxxxx@microsoft.com for more information.

This posting is provided “AS IS” with no warranties, and confers no rights.

“Phil Barila” wrote in message
news:xxxxx@ntdev…
> Yes, it is a manual queue. We’ve (mostly) implemented the WDF version of
> Extreme DMA in a lab test harness. We use one manual queue for reqs when
> they are ready to start, and another one for reqs that have been started.
>
> There isn’t an issue with the queue we use to keep the ready reqs, since
> we just pull the next one off the front. We’re only using the in-progress
> queue as a cancellation container. Perhaps we should rethink that and
> just use WdfRequestMarkCancellable? Seems like that would simplify things
> a lot.
>
> Thanks,
>
> Phil
> –
> Philip D. Barila Windows DDK MVP
> Seagate Technology LLC
> (720) 684-1842
> As if I need to say it: Not speaking for Seagate.
>
>
> “Doron Holan” wrote in message
> news:xxxxx@ntdev…
> Find request is only for a manual queue. If you are using other types
> of queues then you don’t need to find/retrieve it. You can just
> complete the request (assuming you have removed any cancel routine you
> have previously set).
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
> Sent: Friday, April 28, 2006 4:42 PM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST from
> a WDFQUEUE?
>
> xxxxx@seagate.com wrote:
>
>> WDF_REQUEST_PARAMETERS parms;
>> WDFREQUEST finder;
>>
>> NTSTATUS status;
>> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>>
>> if(reqQueue)
>> {
>> WDF_REQUEST_PARAMETERS_INIT(&parms);
>> WdfRequestGetParameters(Request, &parms);
>> // Is parms really an output like the prototype says, or an input
>> like
>> // the doc description says?
>> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
>> &finder);
>> if(NT_SUCCESS(status))
>> {
>> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
>> &Request);
>> // Doc says I need to do this…
>> WdfObjectDereference(finder);
>>
>
> That can’t be right. “finder” is uninitialized at this point.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
>

To clarify here, the request is still *in* a queue (it could be the top
level dispatching queue or some other queu), but the point here is that
it is in a queue until it is completed. Semantically how you want to
describe this is up to you, but implementation wise the request has to
live somewhere :wink:

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jake Oshins
Sent: Monday, May 01, 2006 8:43 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

I’ve been writing WDF/KMDF drivers for about three years now. My first
thought was about like yours. Leave a WDFREQUEST in a queue while I’m
operating on it to make cancelation and organization simple.

What I’ve discovered in those three years is that just isn’t what WDF
queues
were meant for. Today, I only use WDF queues for requests that I have
not
started any processing on. As soon as I start, it comes out of the
queue
and goes onto one of several work lists. If appropriate, it also
becomes
cancellable by calling WdfRequestMarkCancellable.

Incidentally, as I started to make this realization, I started putting
my
in-progress requests into collections. I stopped doing that, too, as
the
collection API can fail, greatly complicating my state management. I
now
use plain old linked lists in the request contexts.


Jake Oshins
Windows Kernel Group

The Virtual Machine Team at Microsoft is hiring. Contact
xxxxx@microsoft.com for more information.

This posting is provided “AS IS” with no warranties, and confers no
rights.

“Phil Barila” wrote in message
news:xxxxx@ntdev…
> Yes, it is a manual queue. We’ve (mostly) implemented the WDF version
of
> Extreme DMA in a lab test harness. We use one manual queue for reqs
when
> they are ready to start, and another one for reqs that have been
started.
>
> There isn’t an issue with the queue we use to keep the ready reqs,
since
> we just pull the next one off the front. We’re only using the
in-progress
> queue as a cancellation container. Perhaps we should rethink that and

> just use WdfRequestMarkCancellable? Seems like that would simplify
things
> a lot.
>
> Thanks,
>
> Phil
> –
> Philip D. Barila Windows DDK MVP
> Seagate Technology LLC
> (720) 684-1842
> As if I need to say it: Not speaking for Seagate.
>
>
> “Doron Holan” wrote in message
> news:xxxxx@ntdev…
> Find request is only for a manual queue. If you are using other types
> of queues then you don’t need to find/retrieve it. You can just
> complete the request (assuming you have removed any cancel routine you
> have previously set).
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
> Sent: Friday, April 28, 2006 4:42 PM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Is there an easier way to remove a WDFREQUEST
from
> a WDFQUEUE?
>
> xxxxx@seagate.com wrote:
>
>> WDF_REQUEST_PARAMETERS parms;
>> WDFREQUEST finder;
>>
>> NTSTATUS status;
>> WDFQUEUE reqQueue = WdfRequestGetIoQueue(Request);
>>
>> if(reqQueue)
>> {
>> WDF_REQUEST_PARAMETERS_INIT(&parms);
>> WdfRequestGetParameters(Request, &parms);
>> // Is parms really an output like the prototype says, or an input
>> like
>> // the doc description says?
>> status = WdfIoQueueFindRequest(reqQueue, NULL, NULL, &parms,
>> &finder);
>> if(NT_SUCCESS(status))
>> {
>> status = WdfIoQueueRetrieveFoundRequest(reqQueue, finder,
>> &Request);
>> // Doc says I need to do this…
>> WdfObjectDereference(finder);
>>
>
> That can’t be right. “finder” is uninitialized at this point.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Doron,

What’s the KMDF definition of a “non sequential queue”? I can only find
Sequential, Parallel, and Manual dispatching types. Are you suggesting
that I use WdfIoQueueDispatchParallel with no EvtIoYYY routines?

Remember that I have two queues, a Ready Q, of stuff that’s fully prepped
for hanging on the hardware, and an In Progress Q, of stuff that’s already
on the hardware. Both of them were Manual, and that worked reasonably
well for the Ready Q, but has been a pain for the In Progress Q.

Although I haven’t finished the coding, I’m converting the Ready Q to
WdfIoQueueDispatchParallel and have assigned an EvtIoDefault routine for
that Queue, so every time I stick something in there, the Default routine
will get called ASAP, which will hang it on the hardware, or requeue it if
there isn’t room on the hardware. No problem there. I’m using that
WDFQUEUE in a manner that it’s intended, and unless I’m misreading the
docs, that should work well for us.

It’s the Q of stuff that’s already on the hardware that is causing
trouble.
I don’t want any automatic dispatching, I really don’t want or need a
callback when something’s been inserted. I do want a Cancellation
callback, and that part already works.
I need to be able to remove an arbitrarily positioned WDFREQUEST from it
more conveniently than FindFirst/FindNext/FindClose, and perhaps your “non
sequential queue” is good for that. I am not trying to *get* a
WDFREQUEST, I’m trying to remove a specific one. This occurs as a result
of either an interrupt (command completion) or a timer firing (command
timeout).

Given the above, I’d really appreciate some more detail on “non sequential
queue”, “shove the request into the queue”, and why I would want to set a
cancel routine on the request if I’m using the WDFQUEUE (and its
EvtCanceledOnIoQueue callback) to manage cancellation for me?

If the WDFQUEUE can be used the way I described above, it’s apparent that
there is at least one WDFQUEUE usage model that I don’t grok, which isn’t
too surprising. I anticipate being educated.

Thanks,

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, May 01, 2006 6:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Why do you need a manual queue at all? Just park all of your requeusts
in a non sequential queue. Since you are already tracking the
wdfrequest separately, you just shove the request into the queue,
(optionally) set the cancel routine and then complete the request when
it is done (removing the optional cancel routine first if needed). If
you just need a container of requests that handles cancellation for you,
this is the way to go.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 3:45 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Peter,

I tried WdfIoQueueFindRequest with the WDFREQUEST I was looking for.
The
req wasn’t found, and I know it hadn’t been cancelled or completed yet.
And it makes sense. The WDFREQUEST parameter to WdfIoQueueFindRequest
is
labeled Previous for a reason, and that is that it’s documented as the
starting point for a search. Although I don’t have a clue how it’s
implemented, it appears from external evidence that
WdfIoQueueFindRequest
assumes that its only usage model is the FindFirst/FindNext/FindClose
model. It doesn’t appear to be capable of returning the Request you
already have.

If I already have a WDFREQUEST, and I know which WDFQUEUE it’s in, the
logical thing to do would be to simply do a
WdfIoQueueRemoveRequest(WDFQUEUE Queue, WDFREQUEST Request), don’t you
think?

Too bad there isn’t one of those. The closest thing to that is
WdfIoQueueRetrieveFoundRequest().

Although calling WdfIoQueueRetrieveFoundRequest() with the WDFREQUEST I
already have appears to work safely in this generation of WDF, the docs
clearly say that you need to do WdfIoQueueFindRequest first, and don’t
forget to dereference the find handle when you are done. Hence my
reluctance to use it, since it adds a lot of code overhead to a very
simple operation.

Peter, I appreciate that “all WDF, all the time” is desirable, but let’s
face an inescapable fact: WDFQUEUEs weren’t designed to be used as
vectors, they were designed primarily as single-ended queues, and using
them that way works very well. Trying to use them as a vector, which is
really what we were doing, is stretching the utility of the WDFQUEUE
beyond where it is equipped to go without serious usability compromises.
So I don’t offer much of a criticism of the WDFQUEUE, it would be nice
if
it were more conveniently used as a vector, but it’s not, and I assume
that wasn’t part of the design requirement.

Allow me to append the caveat that I might be horribly misunderstanding
the WDFQUEUE model badly, but since both you and Doron both have said
“Use
WdfIoQueueFindRequest()”, I doubt that I’m completely out in the weeds,
so
I think my analysis is reasonably sound. Please correct me where
appropriate.

Thanks,

BTW, I implemented the Mark/UnmarkCancelable and EvtRequestCancel
callback
in about 10 lines of real code, plus liberal comments. In our
environment, that was clearly the way to go. If the WDFQUEUE didn’t
have
the ugly overhead involved, it would have been a wash, and I would have
left it the way it was.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, May 01, 2006 2:59 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

WdfIoQueueFindRequest will look for a specific request if you hand it
the reqeust handle. Think of it as referencing the request for your iff
it hasn’t yet been cancelled or completed.

So you don’t need to iterate through the queue. You can make a single
call.

-p


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

We had originally extracted the IRP from WDFREQUEST, and then stuffed the
IRP on a CSQ. This is sounding like we should have remained with CSQs.

Gary G. Little

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Philip D Barila
Sent: Tuesday, May 02, 2006 12:20 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Doron,

What’s the KMDF definition of a “non sequential queue”? I can only find
Sequential, Parallel, and Manual dispatching types. Are you suggesting
that I use WdfIoQueueDispatchParallel with no EvtIoYYY routines?

Remember that I have two queues, a Ready Q, of stuff that’s fully prepped
for hanging on the hardware, and an In Progress Q, of stuff that’s already
on the hardware. Both of them were Manual, and that worked reasonably
well for the Ready Q, but has been a pain for the In Progress Q.

Although I haven’t finished the coding, I’m converting the Ready Q to
WdfIoQueueDispatchParallel and have assigned an EvtIoDefault routine for
that Queue, so every time I stick something in there, the Default routine
will get called ASAP, which will hang it on the hardware, or requeue it if
there isn’t room on the hardware. No problem there. I’m using that
WDFQUEUE in a manner that it’s intended, and unless I’m misreading the
docs, that should work well for us.

It’s the Q of stuff that’s already on the hardware that is causing
trouble.
I don’t want any automatic dispatching, I really don’t want or need a
callback when something’s been inserted. I do want a Cancellation
callback, and that part already works.
I need to be able to remove an arbitrarily positioned WDFREQUEST from it
more conveniently than FindFirst/FindNext/FindClose, and perhaps your “non
sequential queue” is good for that. I am not trying to *get* a
WDFREQUEST, I’m trying to remove a specific one. This occurs as a result
of either an interrupt (command completion) or a timer firing (command
timeout).

Given the above, I’d really appreciate some more detail on “non sequential
queue”, “shove the request into the queue”, and why I would want to set a
cancel routine on the request if I’m using the WDFQUEUE (and its
EvtCanceledOnIoQueue callback) to manage cancellation for me?

If the WDFQUEUE can be used the way I described above, it’s apparent that
there is at least one WDFQUEUE usage model that I don’t grok, which isn’t
too surprising. I anticipate being educated.

Thanks,

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, May 01, 2006 6:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from a
WDFQUEUE?

Why do you need a manual queue at all? Just park all of your requeusts
in a non sequential queue. Since you are already tracking the
wdfrequest separately, you just shove the request into the queue,
(optionally) set the cancel routine and then complete the request when
it is done (removing the optional cancel routine first if needed). If
you just need a container of requests that handles cancellation for you,
this is the way to go.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 3:45 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Peter,

I tried WdfIoQueueFindRequest with the WDFREQUEST I was looking for.
The
req wasn’t found, and I know it hadn’t been cancelled or completed yet.
And it makes sense. The WDFREQUEST parameter to WdfIoQueueFindRequest
is
labeled Previous for a reason, and that is that it’s documented as the
starting point for a search. Although I don’t have a clue how it’s
implemented, it appears from external evidence that
WdfIoQueueFindRequest
assumes that its only usage model is the FindFirst/FindNext/FindClose
model. It doesn’t appear to be capable of returning the Request you
already have.

If I already have a WDFREQUEST, and I know which WDFQUEUE it’s in, the
logical thing to do would be to simply do a
WdfIoQueueRemoveRequest(WDFQUEUE Queue, WDFREQUEST Request), don’t you
think?

Too bad there isn’t one of those. The closest thing to that is
WdfIoQueueRetrieveFoundRequest().

Although calling WdfIoQueueRetrieveFoundRequest() with the WDFREQUEST I
already have appears to work safely in this generation of WDF, the docs
clearly say that you need to do WdfIoQueueFindRequest first, and don’t
forget to dereference the find handle when you are done. Hence my
reluctance to use it, since it adds a lot of code overhead to a very
simple operation.

Peter, I appreciate that “all WDF, all the time” is desirable, but let’s
face an inescapable fact: WDFQUEUEs weren’t designed to be used as
vectors, they were designed primarily as single-ended queues, and using
them that way works very well. Trying to use them as a vector, which is
really what we were doing, is stretching the utility of the WDFQUEUE
beyond where it is equipped to go without serious usability compromises.
So I don’t offer much of a criticism of the WDFQUEUE, it would be nice
if
it were more conveniently used as a vector, but it’s not, and I assume
that wasn’t part of the design requirement.

Allow me to append the caveat that I might be horribly misunderstanding
the WDFQUEUE model badly, but since both you and Doron both have said
“Use
WdfIoQueueFindRequest()”, I doubt that I’m completely out in the weeds,
so
I think my analysis is reasonably sound. Please correct me where
appropriate.

Thanks,

BTW, I implemented the Mark/UnmarkCancelable and EvtRequestCancel
callback
in about 10 lines of real code, plus liberal comments. In our
environment, that was clearly the way to go. If the WDFQUEUE didn’t
have
the ugly overhead involved, it would have been a wash, and I would have
left it the way it was.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, May 01, 2006 2:59 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

WdfIoQueueFindRequest will look for a specific request if you hand it
the reqeust handle. Think of it as referencing the request for your iff
it hasn’t yet been cancelled or completed.

So you don’t need to iterate through the queue. You can make a single
call.

-p


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

That would be a bad idea. KMDF uses DriverContext in the irp for some
book keeping, I am pretty sure the WDFQUEUE uses the same fields as the
CSQ. It could only come into play for cancellation logic in which case
you are OK b/c you are not setting a KMDF cancel routine, but if all you
are doing is putting it on a csq, why not have a parallel WDFQUEUE and
be done with it?

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Tuesday, May 02, 2006 10:34 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

We had originally extracted the IRP from WDFREQUEST, and then stuffed
the
IRP on a CSQ. This is sounding like we should have remained with CSQs.

Gary G. Little

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Philip D Barila
Sent: Tuesday, May 02, 2006 12:20 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

Doron,

What’s the KMDF definition of a “non sequential queue”? I can only find
Sequential, Parallel, and Manual dispatching types. Are you suggesting
that I use WdfIoQueueDispatchParallel with no EvtIoYYY routines?

Remember that I have two queues, a Ready Q, of stuff that’s fully
prepped
for hanging on the hardware, and an In Progress Q, of stuff that’s
already
on the hardware. Both of them were Manual, and that worked reasonably
well for the Ready Q, but has been a pain for the In Progress Q.

Although I haven’t finished the coding, I’m converting the Ready Q to
WdfIoQueueDispatchParallel and have assigned an EvtIoDefault routine for
that Queue, so every time I stick something in there, the Default
routine
will get called ASAP, which will hang it on the hardware, or requeue it
if
there isn’t room on the hardware. No problem there. I’m using that
WDFQUEUE in a manner that it’s intended, and unless I’m misreading the
docs, that should work well for us.

It’s the Q of stuff that’s already on the hardware that is causing
trouble.
I don’t want any automatic dispatching, I really don’t want or need a
callback when something’s been inserted. I do want a Cancellation
callback, and that part already works.
I need to be able to remove an arbitrarily positioned WDFREQUEST from it
more conveniently than FindFirst/FindNext/FindClose, and perhaps your
“non
sequential queue” is good for that. I am not trying to *get* a
WDFREQUEST, I’m trying to remove a specific one. This occurs as a
result
of either an interrupt (command completion) or a timer firing (command
timeout).

Given the above, I’d really appreciate some more detail on “non
sequential
queue”, “shove the request into the queue”, and why I would want to set
a
cancel routine on the request if I’m using the WDFQUEUE (and its
EvtCanceledOnIoQueue callback) to manage cancellation for me?

If the WDFQUEUE can be used the way I described above, it’s apparent
that
there is at least one WDFQUEUE usage model that I don’t grok, which
isn’t
too surprising. I anticipate being educated.

Thanks,

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, May 01, 2006 6:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

Why do you need a manual queue at all? Just park all of your requeusts
in a non sequential queue. Since you are already tracking the
wdfrequest separately, you just shove the request into the queue,
(optionally) set the cancel routine and then complete the request when
it is done (removing the optional cancel routine first if needed). If
you just need a container of requests that handles cancellation for you,
this is the way to go.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 3:45 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Peter,

I tried WdfIoQueueFindRequest with the WDFREQUEST I was looking for.
The
req wasn’t found, and I know it hadn’t been cancelled or completed yet.
And it makes sense. The WDFREQUEST parameter to WdfIoQueueFindRequest
is
labeled Previous for a reason, and that is that it’s documented as the
starting point for a search. Although I don’t have a clue how it’s
implemented, it appears from external evidence that
WdfIoQueueFindRequest
assumes that its only usage model is the FindFirst/FindNext/FindClose
model. It doesn’t appear to be capable of returning the Request you
already have.

If I already have a WDFREQUEST, and I know which WDFQUEUE it’s in, the
logical thing to do would be to simply do a
WdfIoQueueRemoveRequest(WDFQUEUE Queue, WDFREQUEST Request), don’t you
think?

Too bad there isn’t one of those. The closest thing to that is
WdfIoQueueRetrieveFoundRequest().

Although calling WdfIoQueueRetrieveFoundRequest() with the WDFREQUEST I
already have appears to work safely in this generation of WDF, the docs
clearly say that you need to do WdfIoQueueFindRequest first, and don’t
forget to dereference the find handle when you are done. Hence my
reluctance to use it, since it adds a lot of code overhead to a very
simple operation.

Peter, I appreciate that “all WDF, all the time” is desirable, but let’s
face an inescapable fact: WDFQUEUEs weren’t designed to be used as
vectors, they were designed primarily as single-ended queues, and using
them that way works very well. Trying to use them as a vector, which is
really what we were doing, is stretching the utility of the WDFQUEUE
beyond where it is equipped to go without serious usability compromises.
So I don’t offer much of a criticism of the WDFQUEUE, it would be nice
if
it were more conveniently used as a vector, but it’s not, and I assume
that wasn’t part of the design requirement.

Allow me to append the caveat that I might be horribly misunderstanding
the WDFQUEUE model badly, but since both you and Doron both have said
“Use
WdfIoQueueFindRequest()”, I doubt that I’m completely out in the weeds,
so
I think my analysis is reasonably sound. Please correct me where
appropriate.

Thanks,

BTW, I implemented the Mark/UnmarkCancelable and EvtRequestCancel
callback
in about 10 lines of real code, plus liberal comments. In our
environment, that was clearly the way to go. If the WDFQUEUE didn’t
have
the ugly overhead involved, it would have been a wash, and I would have
left it the way it was.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, May 01, 2006 2:59 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

WdfIoQueueFindRequest will look for a specific request if you hand it
the reqeust handle. Think of it as referencing the request for your iff
it hasn’t yet been cancelled or completed.

So you don’t need to iterate through the queue. You can make a single
call.

-p


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Non sequential == parallel. I couldn’t remember the term yesterday

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Tuesday, May 02, 2006 10:20 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Doron,

What’s the KMDF definition of a “non sequential queue”? I can only find
Sequential, Parallel, and Manual dispatching types. Are you suggesting
that I use WdfIoQueueDispatchParallel with no EvtIoYYY routines?

Remember that I have two queues, a Ready Q, of stuff that’s fully
prepped
for hanging on the hardware, and an In Progress Q, of stuff that’s
already
on the hardware. Both of them were Manual, and that worked reasonably
well for the Ready Q, but has been a pain for the In Progress Q.

Although I haven’t finished the coding, I’m converting the Ready Q to
WdfIoQueueDispatchParallel and have assigned an EvtIoDefault routine for
that Queue, so every time I stick something in there, the Default
routine
will get called ASAP, which will hang it on the hardware, or requeue it
if
there isn’t room on the hardware. No problem there. I’m using that
WDFQUEUE in a manner that it’s intended, and unless I’m misreading the
docs, that should work well for us.

It’s the Q of stuff that’s already on the hardware that is causing
trouble.
I don’t want any automatic dispatching, I really don’t want or need a
callback when something’s been inserted. I do want a Cancellation
callback, and that part already works.
I need to be able to remove an arbitrarily positioned WDFREQUEST from it
more conveniently than FindFirst/FindNext/FindClose, and perhaps your
“non
sequential queue” is good for that. I am not trying to *get* a
WDFREQUEST, I’m trying to remove a specific one. This occurs as a
result
of either an interrupt (command completion) or a timer firing (command
timeout).

Given the above, I’d really appreciate some more detail on “non
sequential
queue”, “shove the request into the queue”, and why I would want to set
a
cancel routine on the request if I’m using the WDFQUEUE (and its
EvtCanceledOnIoQueue callback) to manage cancellation for me?

If the WDFQUEUE can be used the way I described above, it’s apparent
that
there is at least one WDFQUEUE usage model that I don’t grok, which
isn’t
too surprising. I anticipate being educated.

Thanks,

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, May 01, 2006 6:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

Why do you need a manual queue at all? Just park all of your requeusts
in a non sequential queue. Since you are already tracking the
wdfrequest separately, you just shove the request into the queue,
(optionally) set the cancel routine and then complete the request when
it is done (removing the optional cancel routine first if needed). If
you just need a container of requests that handles cancellation for you,
this is the way to go.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@seagate.com
Sent: Monday, May 01, 2006 3:45 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a WDFQUEUE?

Peter,

I tried WdfIoQueueFindRequest with the WDFREQUEST I was looking for.
The
req wasn’t found, and I know it hadn’t been cancelled or completed yet.
And it makes sense. The WDFREQUEST parameter to WdfIoQueueFindRequest
is
labeled Previous for a reason, and that is that it’s documented as the
starting point for a search. Although I don’t have a clue how it’s
implemented, it appears from external evidence that
WdfIoQueueFindRequest
assumes that its only usage model is the FindFirst/FindNext/FindClose
model. It doesn’t appear to be capable of returning the Request you
already have.

If I already have a WDFREQUEST, and I know which WDFQUEUE it’s in, the
logical thing to do would be to simply do a
WdfIoQueueRemoveRequest(WDFQUEUE Queue, WDFREQUEST Request), don’t you
think?

Too bad there isn’t one of those. The closest thing to that is
WdfIoQueueRetrieveFoundRequest().

Although calling WdfIoQueueRetrieveFoundRequest() with the WDFREQUEST I
already have appears to work safely in this generation of WDF, the docs
clearly say that you need to do WdfIoQueueFindRequest first, and don’t
forget to dereference the find handle when you are done. Hence my
reluctance to use it, since it adds a lot of code overhead to a very
simple operation.

Peter, I appreciate that “all WDF, all the time” is desirable, but let’s
face an inescapable fact: WDFQUEUEs weren’t designed to be used as
vectors, they were designed primarily as single-ended queues, and using
them that way works very well. Trying to use them as a vector, which is
really what we were doing, is stretching the utility of the WDFQUEUE
beyond where it is equipped to go without serious usability compromises.
So I don’t offer much of a criticism of the WDFQUEUE, it would be nice
if
it were more conveniently used as a vector, but it’s not, and I assume
that wasn’t part of the design requirement.

Allow me to append the caveat that I might be horribly misunderstanding
the WDFQUEUE model badly, but since both you and Doron both have said
“Use
WdfIoQueueFindRequest()”, I doubt that I’m completely out in the weeds,
so
I think my analysis is reasonably sound. Please correct me where
appropriate.

Thanks,

BTW, I implemented the Mark/UnmarkCancelable and EvtRequestCancel
callback
in about 10 lines of real code, plus liberal comments. In our
environment, that was clearly the way to go. If the WDFQUEUE didn’t
have
the ugly overhead involved, it would have been a wash, and I would have
left it the way it was.

Phil

Philip D. Barila
Seagate Technology LLC
(720) 684-1842

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, May 01, 2006 2:59 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Is there an easier way to remove a WDFREQUEST from
a
WDFQUEUE?

WdfIoQueueFindRequest will look for a specific request if you hand it
the reqeust handle. Think of it as referencing the request for your iff
it hasn’t yet been cancelled or completed.

So you don’t need to iterate through the queue. You can make a single
call.

-p


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer