ZLP

Hi all,

which is the correct way to implement ‘zero length packet’ transmission on a
bulk endpoint in a KMDF USB driver when payload length is an integer
multiple of packet size ?

I suppose to:

  1. Detect the ZLP condition in EvtIoWrite() (set flag in device
    context)

  2. In the normal write completion routine if ZLP is required allocate
    an empty request by WdfRequestCreate()

  3. Use WdfUsbTargetPipeFormatRequestForWrite() with NULL value in
    WDFMEMORY parameter (it is OPTIONAL in function prototype)

  4. Assign a dedicated specific completion routine for this request and
    send the request

  5. Complete the user request by WdfRequestCompleteWithInformation()

  6. In the specific completion routine use WdfObjectDelete to release
    the WDFREQUEST object

Any suggestion & comment will be highly appreciated,

PaoloC

That mostly work. If you are reusing the callers request to send all of the io previous to the zlp, you can still use the callers request for the zlp too. I wouldn’t complete the callers request until the zlp write returned back to you though

d

Bent from my phone


From: Paolo Cazzolamailto:xxxxx
Sent: ?4/?30/?2013 2:21 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] ZLP

Hi all,
which is the correct way to implement ?zero length packet? transmission on a bulk endpoint in a KMDF USB driver when payload length is an integer multiple of packet size ?
I suppose to:

1) Detect the ZLP condition in EvtIoWrite() (set flag in device context)

2) In the normal write completion routine if ZLP is required allocate an empty request by WdfRequestCreate()

3) Use WdfUsbTargetPipeFormatRequestForWrite() with NULL value in WDFMEMORY parameter (it is OPTIONAL in function prototype)

4) Assign a dedicated specific completion routine for this request and send the request

5) Complete the user request by WdfRequestCompleteWithInformation()

6) In the specific completion routine use WdfObjectDelete to release the WDFREQUEST object

Any suggestion & comment will be highly appreciated,
PaoloC


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

Zero IS an integer multiple of the packet size.

Have you TRIED this and are having a problem, or do you just want to know where to start?

Peter
OSR

@Peter:

As much as the host is able to detect the transaction boundaries by using short and zero length packets, th device can use a similar approach to be able to separate one transaction from another. In case the transaction is a multiple of packet size, the host driver needs to send a ZLP to tell the device the data is all sent.

I realize that. What was it in my reply that lead you to think I didn’t?

Peter
OSR

Thanks a lot everyone.

@Doron

I see in WdfRequestReuse documentation the following comment :

?Drivers must not attempt to reuse request objects that they have received
from the framework.?

So I?m going allocate a dedicated WDFREQUEST for the ZLP.

@Peter

I have not yet tried this, I am investigating the best way to do for an
existing driver.

PaoloC

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, April 30, 2013 11:24 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] ZLP

That mostly work. If you are reusing the callers request to send all of the
io previous to the zlp, you can still use the callers request for the zlp
too. I wouldn’t complete the callers request until the zlp write returned
back to you though

d

Bent from my phone


From: Paolo Cazzola mailto:xxxxx
Sent: ?4/?30/?2013 2:21 PM
To: Windows System Software Devs Interest List mailto:xxxxx
Subject: [ntdev] ZLP

Hi all,

which is the correct way to implement ?zero length packet? transmission on a
bulk endpoint in a KMDF USB driver when payload length is an integer
multiple of packet size ?

I suppose to:

1) Detect the ZLP condition in EvtIoWrite() (set flag in device
context)

2) In the normal write completion routine if ZLP is required allocate
an empty request by WdfRequestCreate()

3) Use WdfUsbTargetPipeFormatRequestForWrite() with NULL value in
WDFMEMORY parameter (it is OPTIONAL in function prototype)

4) Assign a dedicated specific completion routine for this request and
send the request

5) Complete the user request by WdfRequestCompleteWithInformation()

6) In the specific completion routine use WdfObjectDelete to release
the WDFREQUEST object

Any suggestion & comment will be highly appreciated,

PaoloC


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

_____

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3272 / Virus Database: 3162/6286 - Release Date: 04/30/13</mailto:xxxxx></mailto:xxxxx>

WdfRequestReuse doesn’t need to come into play. For ping ponging the user’s request down the stack multiple times and then competing it, you don’t need to call WdfRequestReuse

d

Bent from my phone


From: Paolo Cazzolamailto:xxxxx
Sent: ?5/?1/?2013 2:34 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE: [ntdev] ZLP

Thanks a lot everyone.

@Doron
I see in WdfRequestReuse documentation the following comment :
?Drivers must not attempt to reuse request objects that they have received from the framework.?
So I?m going allocate a dedicated WDFREQUEST for the ZLP.

@Peter
I have not yet tried this, I am investigating the best way to do for an existing driver.

PaoloC

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Tuesday, April 30, 2013 11:24 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] ZLP

That mostly work. If you are reusing the callers request to send all of the io previous to the zlp, you can still use the callers request for the zlp too. I wouldn’t complete the callers request until the zlp write returned back to you though

d

Bent from my phone

From: Paolo Cazzolamailto:xxxxx
Sent: ?4/?30/?2013 2:21 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: [ntdev] ZLP
Hi all,
which is the correct way to implement ?zero length packet? transmission on a bulk endpoint in a KMDF USB driver when payload length is an integer multiple of packet size ?
I suppose to:

1) Detect the ZLP condition in EvtIoWrite() (set flag in device context)

2) In the normal write completion routine if ZLP is required allocate an empty request by WdfRequestCreate()

3) Use WdfUsbTargetPipeFormatRequestForWrite() with NULL value in WDFMEMORY parameter (it is OPTIONAL in function prototype)

4) Assign a dedicated specific completion routine for this request and send the request

5) Complete the user request by WdfRequestCompleteWithInformation()

6) In the specific completion routine use WdfObjectDelete to release the WDFREQUEST object

Any suggestion & comment will be highly appreciated,
PaoloC


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

No virus found in this message.
Checked by AVG - www.avg.comhttp:
Version: 2013.0.3272 / Virus Database: 3162/6286 - Release Date: 04/30/13


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

xxxxx@osr.com wrote:

I realize that. What was it in my reply that lead you to think I didn’t?

I was pretty sure you did, but I have to say I also was confused by what
you were trying to say in your reply. The original poster was asking
how to send a ZLP to signal “end of transfer” when the transfer is an
even multiple of the packet length. In that case, the fact that “zero”
happens to be an even multiple of the packet length is irrelevant. That
terminating packet is not a separate transfer. It’s a part of the
previous transfer – the one we are trying to complete.


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

It would be helpful, if USBD design from the beginning had an URB flag for appending a ZLP for OUT transaction. Unfortunately, it didn’t happen.

Ah, well, cough cough… THAT would be because I misread the OPs question as “I need to send a zlp, but I must send a transfer that an integer multiple of the max packet size.” Hence my comment that zero IS an integer multiple of the max packet size.

Lesson: I should read more carefully.

Thanks Mr Roberts *and* Mr. Grig.

Peter
OSR

Sorry for my poor English that caused the confusion.
PaoloC

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Wednesday, May 01, 2013 8:24 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] ZLP

Ah, well, cough cough… THAT would be because I misread the OPs question as
“I need to send a zlp, but I must send a transfer that an integer multiple
of the max packet size.” Hence my comment that zero IS an integer multiple
of the max packet size.

Lesson: I should read more carefully.

Thanks Mr Roberts *and* Mr. Grig.

Peter
OSR


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3272 / Virus Database: 3162/6289 - Release Date: 05/01/13

No, no, Mr. PaoloC… not your fault at all. It was my fast reading (on my iPad at that). The English in your posts was clearly better than that in my answers.

Hope we were able to help, amid the confusion my hastiness introduced.

Peter
OSR